Configuration
You can configure the widget during launch by setting thewindow.chtlConfig object, as shown below.
chatIconVisible
Whether to display the chat icon (open and close buttons).
- Possible values:
true,false - Default:
true
displayType
The type of widget to display.
- Possible values:
floating,fullscreen,page_inline - Default:
floating
language
The language of the widget in ISO 639-1 format. This will override the language set in your chatbot’s appearance settings.
- Possible values:
en,ar,az,bg,bn,bs,ca,cs,da,de,el,en,es,et,fa,fi,fr,he,hi,hr,hu,hy,id,it,ja,ko,lt,lv,mn,ms,nl,no,pl,pt,pt-br,ro,ru,sk,sl,sq,sr,sv,th,tr,uk,ur,vi,zh-cn,zh-tw
variables
An object containing variable names and their values to pass to the chatbot during launch. The variables must have been created in your chatbot or AI agent and the names must match exactly.
Methods
Below are the SDK methods you can call to interact with the widget.You must wait for the widget script to load before calling these methods.
open()
Opens the chatbot, similar to when a user clicks the chat icon.
minimize()
Minimizes the chatbot, similar to when a user clicks the minimize button in the widget.
hideChatIcon()
Hides the chat icon.
showChatIcon()
Shows the chat icon.
setVariables()
You can pass custom values to the chatbot at any point after it’s loaded.
The method takes an object containing the variable names and values. You must make sure that the variables have been created in the builder and that the names match exactly.
To pass custom data during launch, read this guide.
sendMessage()
Sends a message to your AI agent on behalf of the user, as if they had typed it. The AI agent replies in the widget as usual.
The widget opens automatically if it’s minimized, unless you set open to false. A new conversation is started if the user doesn’t have one yet. If you call it before the widget has finished loading, the message is sent once it’s ready.
sendMessage() only works with AI agents, and only while the chat is in AI mode. It fails if a team member has taken over the conversation or the conversation has ended.hidden: whentrue, the message isn’t shown to the user in the widget or in their transcript. The AI agent still reads it and replies to it. Default:false.open: whenfalse, the widget stays minimized and the reply is waiting for the user when they open it. The user isn’t notified of the reply. Has no effect whendisplayTypeisfullscreenorpage_inline. Default:true.
sendMessage() are labelled “Sent by website” in your inbox and transcripts. They don’t count as the user interacting with the widget, so the conversation only appears in your inbox and analytics once the user interacts with the widget themselves.