intercom-rails icon indicating copy to clipboard operation
intercom-rails copied to clipboard

How do I arbitrarily show/hide the intercom widget with js?

Open SephReed opened this issue 5 years ago • 3 comments

Something like Intercom.show(); Intercom.hide() would be nice. What's the function call for this?

SephReed avatar Sep 12 '19 15:09 SephReed

I found this: https://developers.intercom.com/installing-intercom/docs/intercom-javascript#section-intercomhide

This will hide the main Messenger panel if it is open. It will not hide the Messenger Launcher.

I'm trying to hide the Messenger Launcher. It gets in the way of my UI at some points. I'm not finding any function for this yet.

SephReed avatar Sep 12 '19 15:09 SephReed

A semi functional solution is to just force it:

function setIntercomVisible(shouldShow) {
  const intercomId = "intercom-container";
  const domNode = document.getElementById(intercomId);
  if (domNode) {
    domNode.style.display = shouldShow ? "" : "none";
  } else {
    console.warn(`No element of id "${intercomId}" was found`);
  }
}

SephReed avatar Sep 12 '19 15:09 SephReed

If anyone is still looking for this, you can hide using the JS lib:

Intercom("update", { "hide_default_launcher": true });

Taken from https://www.intercom.com/help/en/articles/189-turn-off-show-or-hide-the-intercom-messenger

lmansur avatar Sep 30 '21 14:09 lmansur