Widget API
Opening and Closing
open()
Opens the conversation widget (noop when embedded)
web1on1.open();
close()
Closes the conversation widget (noop when embedded)
web1on1.close();
isOpened()
Tells if the widget is currently opened or closed.
web1on1.isOpened();
Messages
setPredefinedMessage(message)
Prefills the user's chat input with a predefined message.
web1on1.setPredefinedMessage('I want to book a test drive');
api.showFakeAgentMessage(message, name)
Add a fake agent message(s) to the interface. Name is optional.
web1on1.api.showFakeAgentMessage('Welcome to the chat');
web1on1.api.showFakeAgentMessage('Welcome to the chat', 'Acme Corp');
api.sendClientMessage(message)
Sends a message on the visitor's behalf. The currently loaded conversation will be targeted.
web1on1.api.sendClientMessage('Hello');
Commands and Fields
Prefix the message with >cs
to send command and field messages (or, anything but a regular contact chat message).
You can use this to, when the widget opens, set some conversation information based on data from the webpage. Use case examples:
- set the conversation category, (and use the Wiki articles to show an article when the category is set)
- insert a form and fill in some fields into the conversation
Other use cases involve notifying a team inbox on some page event. Use cases:
- set a permanent conversation meta variable that is used in routing rule conditions to trigger certain routes
- notify a team inbox directly from the widget page
Examples:
Set a contact profile field: location (incl department)
web1on1.api.sendClientMessage('>cs .location 61be87aeafdf672d381a9db4#61be87aeafdf672d381a9db5');
Activate a form
web1on1.api.sendClientMessage('>cs +6093490651a8b5629324ae4f');
Set a form field
web1on1.api.sendClientMessage('>cs .brand Toyota');
Set the conversation category
web1on1.api.sendClientMessage('>cs /set @category Used Car');
Set a conversation meta var
web1on1.api.sendClientMessage('>cs /set isLead yes');
Assign to a user or bot
web1on1.api.sendClientMessage('>cs /assign 62c6077ca980127f404b0301');
Notify an inbox
web1on1.api.sendClientMessage('>cs /notify 605411853c68d83fd1ac7655');
Notify all organizations
web1on1.api.sendClientMessage('>cs /notify');
Mention a user or bot
web1on1.api.sendClientMessage('>cs @6248f0083ab5d5001e523146 Hello this is for you');