I'm trying to implement Intercom into a ReactJS app. I've following their Single Page App instructions. I'm having an issue (perhaps it's by design?) where the little Intercom button in the bottom right won't show up unless a message is sent to the user. I'd like to have the button always visible to the user. When I first integrated, I was able to get the button to show up and was able to send messages as the user no problem, but after some tinkering with the code, I seem to have broken it. What I have so far is:
store.js
import createStore from 'redux';
export default createStore( ... );
intercom.js
import store from './store';
const APP_ID = /* app id */;
/* the intercom JS library */
const updated = false;
window.onload = () => {
Intercom('boot', { app_id: APP_ID };
store.subscribe(() => {
if (typeof document === 'undefined') return;
const state = store.getState();
const currentUser = currentUserSelector(state);
if (currentUser && !updated) {
updated = true;
Intercom('update', {
email: currentUser.email,
user_id: currentUser.id,
name: `${ currentUser.firstName } ${ currentUser.lastName }`
});
}
});
}
and I have require('intercom.js')
in one of the files that is run when the app loads.
There are no errors in the console, the Intercom websocket shows up in Chrome's dev. console, and the client opens when a message is received, but I can't get it to show up when the page loads.
Thanks in advance.
(I've tagged this as React because it's a React app - I don't think this has anything to do with React, but maybe there are some side effects that I don't know of).
Ah ok - simple mistake. Turns out the plan I had subscribed to didn't support non-visitor chat. I had to "upgrade" to the "Resolve Lite" plan - at this point, I could change the messenger behaviour to show the button/messenger to "Users" in the messenger settings view.