Chat widget API
With the Chat widget API it is possible to control the chat widget's behavior and call the JavaScript methods listed below. For example, you can trigger scenarios, hide the chat window or set attributes into an existing conversation.
The chat widget API is active whenever an Ebbot chat widget is loaded on a page. It can be tested through the developer console.
Use hooks to make the widget call a function.
Callback function invoked when widget code is loaded but chat window is not rendered yet
window.Ebbot.onBeforeLoad = function(data) {
// ...
};
Callback function invoked when widget code is loaded and chat window is rendered
window.Ebbot.onLoad = function(data) {
// ...
};
Callback function invoked when conversation is reset
window.Ebbot.onReset = function() {
// ...
};
Callback function invoked after create() API method call.
window.Ebbot.onCreate = function() {
// ...
};
Callback function invoked after destroy() API method call.
window.Ebbot.onDestroy = function() {
// ...
};
Callback function invoked when the chat window is opened
window.Ebbot.onChatWindowOpen = function() {
// ...
};
Callback function invoked when the chat window is closed
window.Ebbot.onChatWindowClose = function() {
// ...
};
Callback function invoked after query result
window.Ebbot.onMessage = function(data) {
// ...
};
Callback function invoked after a bot message is received
window.Ebbot.onBotMessage = function(data) {
// ...
};
Callback function invoked after user types a message
window.Ebbot.onUserMessage = function(data) {
// ...
};
Callback function invoked after query result
window.Ebbot.onStartConversation = function(data) {
// ...
};
Use methods to call a function in the widget.
Create chat widget if does not exist
window.Ebbot.create();
Destroy chat widget if exist
window.Ebbot.destroy();
Displays chat conversation box and initialises the chat
window.ebbot.initChatWindow();
Returns true if the chat is initialized
window.Ebbot.isInitialized();
Reset current session
window.Ebbot.resetSession();
Open chat window
window.Ebbot.openChatWindow();
Close chat window
window.Ebbot.closeChatWindow();
Check if chat window is opened
window.Ebbot.isChatWindowOpened();
Check if chat window is closed
window.Ebbot.isChatWindowClosed();
Send Message
window.Ebbot.sendMessage("Hello !");
Set User Attribute
window.Ebbot.setUserAttribute({ test: "123" });
Trigger Scenario
window.Ebbot.triggerScenario({
scenario: "scenarioId", // Found in the URL of a scenario
state: "stateId"
});
End Chat
window.Ebbot.endChat();
Transcript chat
window.Ebbot.transcriptChat();
Turn on/off chat notifications
window.Ebbot.snoozeChat();
Check if notifications are on/off
window.Ebbot.isSnoozed();
Hide the chat
window.Ebbot.hide();
Show the chat
window.Ebbot.show();
Is the chat window hidden
window.Ebbot.isHidden();
Clears all the messages from the chat window
window.Ebbot.clearChat();
Returns true if the user is/was active
window.Ebbot.isUserActive();
Returns true if the conversation is started
window.Ebbot.isConversationActive();
Returns an object containing the width and height of the widget (including blob, if its not on mobile). As calculations depend on the open animation, it might take 500ms for the size to update.
window.Ebbot.getWidgetSize();
Last modified 14d ago