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.

Hooks

Use hooks to make the widget call a function.

onBeforeLoad

Callback function invoked when widget code is loaded but chat window is not rendered yet

window.Ebbot.onBeforeLoad = function(data) {
  // ...
};

onLoad

Callback function invoked when widget code is loaded and chat window is rendered

window.Ebbot.onLoad = function(data) {
  // ...
};

onReset

Callback function invoked when conversation is reset

onCreate

Callback function invoked after create() API method call.

onDestroy

Callback function invoked after destroy() API method call.

onChatWindowOpen

Callback function invoked when the chat window is opened

onChatWindowClose

Callback function invoked when the chat window is closed

onMessage

Callback function invoked after query result

onBotMessage

Callback function invoked after a bot message is received

onUserMessage

Callback function invoked after user types a message

onStartConversation

Callback function invoked after query result

Methods

Use methods to call a function in the widget.

create

Create chat widget if does not exist

destroy

Destroy chat widget if exist

initChatWindow

Displays chat conversation box and initialises the chat

isInitialized

Returns true if the chat is initialized

resetSession

Reset current session

openChatWindow

Open chat window

closeChatWindow

Close chat window

loadStyle

Load start page style for the Chat Widget, takes style ID as an argument.

isChatWindowOpened

Check if chat window is opened

isChatWindowClosed

Check if chat window is closed

sendMessage

Send Message

setUserAttribute

Set User Attribute

triggerScenario

Trigger Scenario

endChat

End Chat

transcriptChat

Transcript chat

snoozeChat

Turn on/off chat notifications

isSnoozed

Check if notifications are on/off

hide

Hide the chat

show

Show the chat

isHidden

Is the chat window hidden

clearChat

Clears all the messages from the chat window

isUserActive

Returns true if the user is/was active

isConversationActive

Returns true if the conversation is started

getWidgetSize

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.

Last updated

Was this helpful?