Use the available methods to interact with the Laiye Chatbot widget.

MethodDescription
isOpenDestygoChat.isOpen() returns true if the widget chatbox is open and false if not.
wasOpenedDestygoChat.wasOpened() returns true if the widget chatbox has been opened once before and false if not.
unreadMessagesCountDestygoChat.unreadMessagesCount() returns the number of unread messages. A message is unread if it was received while the chatbox was closed and has not been opened since.
messagesDestygoChat.messages() returns the list of messages of the current widget. The result is an array with the two following object possibilities:

{ "author": "'user'||'server'", "text": "the text of the message" }

{ "author": "'user'||'server'", "attachment": {type: "template", payload: {…}} }

Author can be user or server.

There will be either text or attachment in the payload.

An attachment is a template JSON data.
MarkMessagesAsReadDestygoChat.MarkMessagesAsRead() marks all unread messages as read.
ToggleChatOptional parameter : open (boolean)

DestygoChat.ToggleChat() opens or closes the chatbox depending of its parameter.

DestygoChat.ToggleChat() will open the chatbox if it was closed, and close it if it was opened.
DestygoChat.ToggleChat({open: true}) will open the chatbox no matter what the state is.
* DestygoChat.ToggleChat({open: false}) will close the chatbox no matter what the state is.
SendMessageMandatory parameter : text message (string)

DestygoChat.SendMessage('a text message') will send a text message to the bot.
ResetWidgetDestygoChat.ResetWidget() resets the widget state, as if it was a brand new user.
setZendeskUserInfoMandatory parameter : User informations : display_name, email, phone (Object)

The object parameter can handle only these three parameters: display_name, email, phone. This restriction comes from Zendesk and we cannot add any other fields.

DestygoChat.setZendeskUserInfo(UserInfoObject) will send the user informations to Zendesk before the agent handover.

You need to use this function when the following event is triggered: destygo_zendesk_triggered