Once the script tag that loads web chat finished, you can control it using the webchattonic global variable, to modify its behavior.
The following is a list of all the current possibilities.
Use webchattonic.toggleContainer() to open/close the web. You can also use webchattonic.openContainer() or webchattonic.closeContainer() to open or close the web chat respectively.
Use webchattonic.emitBadge() to show a badge with a number of "notifications" to lure the users into opening the web chat window (this can also be set to do automatically after a few seconds every time for every user)
Use webchattonic.emitSound(ARRAY) to play a sound, the method receives an array of urls of sounds with different formats so that it can be played in different browsers. (Supports: mp3, mp4, ogg and wav) (this can also be set to do automatically after a few seconds every time for every user)
Show help message to the user
Use webchattonic.emitMessage(TEXT) to display a text next to the launcher button of the web chat
Disappear help message
Use webchattonic.cleanMessage() to dissapear the message that we showed with the previous function
Use webchattonic.addNotification(CONFIG) to send a "notification" that is generated by adding the badge, emitting sound, showing a message and cleaning that message after a while according to the config we pass it.
The config is a JSON of this style:
message: 'Hello, how can I help you?', (STRING or BOOLEAN)
sound: true, (ARRAY or BOOLEAN)
cleanIn: 3000, (NUMBER (milliseconds))
count: true (BOOLEAN)
If the message is a string I show that message, if I don't show by default "How can I help you?", unless the parameter has not been specified, that is false
If sound is an array equal to the one we would pass to emitSound() those sounds are reproduced, if I don't reproduce a sound by default, unless the parameter has not been specified, that is false
Yes message was specified, cleanIn is specified and is a number the text message will be cleared in that amount of milliseconds, if it is not kept visible until the chat is opened or another notification with text is created.
If count is true is displayed and/or one is added to the notification counter.
Send message as user
Use webchattonic.sendMessage(TEXT) to send a message as the user, in the web chat window, to notify the bot of doing something in particular
Change the current context
Use webchattonic.updateContext(context) to update the current web chat context, that then triggers (optionally) a change context flow to be handled by the bot, and sets the context to be sent in each subsequent message by the user. See https://mobile-tonic.atlassian.net/wiki/spaces/CTP/pages/379748357 for more information on what it does.
Use webchattonic.resetConversation() to reset the current conversation, that will generate a new conversation as a new user. It is important to note that the user will be expired and cannot be recontacted.