intercom / intercom-rails

The easiest way to install Intercom in a Rails app.
https://developers.intercom.io/reference
MIT License
281 stars 108 forks source link

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

Open SephReed opened 4 years ago

SephReed commented 4 years ago

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

SephReed commented 4 years ago

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 commented 4 years ago

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`);
  }
}
lmansur commented 2 years ago

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