Skip to content

Instantly share code, notes, and snippets.

// Wait until the messenger is fully
// ready, then send a message
FxoMessenger.on('stateChanged', function(state) {
if (state === 'connected') {
FxoMessenger.sendMessage('Hey!');
}
});
// Subscribe to all messages received,
// logging them to the console
// Send a simple message
FxoMessenger.sendMessage('Hey!');
// Send a message with metadata
FxoMessenger.sendMessage('Hey!', {
user_id: 12345,
name: 'John Doe'
});
// Set the messenger to open fullscreen
FxoMessenger.setConfig({
fullscreen: true
});
// Set header text and color
FxoMessenger.setConfig({
headerText: 'Chat to Us',
color: '#4B0082'
});
// Set the messenger to open fullscreen
FxoMessenger.getState();
// Returns Object:
// {
// state: "connected",
// color: "#4B0082",
// fullscreen: true,
// headerText: "Chat to Us"
// }
FxoMessenger.create();
FxoMessenger.destroy();
FxoMessenger.toggle();
FxoMessenger.on(eventName, callback)
FxoMessenger.removeListeners(<optional eventName>)
FxoMessenger.on<EventName>(callback)