JavaScript API
Assistant JavaScript API
The Assistant JS API exposes the following methods to the global object: Assistant
. You can use them to control your Assistant programmatically.
Assistant('init', assistantId)
Call this method to load the Assistant
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('trigger-less-init', assistantId)
If you want to initialize assistant without launcher or trigger button, then use this.
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('triggerLess')
Call this method to hide/disable the trigger/launcher button for the Assistant. You might want to use this feature if you are trying to trigger assistant programmatically and don't want to display the launcher button in the bottom.
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('open')
Use this methods to manually open the Assistant
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('close')
Use this methods to manually close the Assistant
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('toggle')
Use this methods to manually toggle the Assistant
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('chat')
Use this methods to manually open the chat. You must have Chat
option enabled from your settings panel. Otherwise this command won't work.
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('contact')
Use this methods to manually open the contact. You can pass any subject and body that will auto populate the form, which can be edited therefore. You must have Contact
option enabled from your settings panel. Otherwise this command won't work.
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('order-status')
Use this methods to manually open the contact. You must have OrderStatus
option enabled from your settings panel. Otherwise this command won't work.
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('identify', userObject)
It tells Assistant that we know the name and email address of the visitor. We use their name and email address to pre-populate and hide the fields on the Contact Form
screen. We also use their name and email address to skip asking some questions at the start of a Assistant chat.
Example use case:
N.B You can use this any way you want with your own logic and everything.
Assistant('article')
There are two ways to open a Knowledge Base article using the Assistant('article')
method on your site. This method lets you display an article either within the Assistant itself or in a sidebar, depending on your needs.
All you'll need is the Article's ID, which can be found in Thrivedesk by navigating to the docs, opening the article in the editor, and copying the ID from there.
This article
method is useful when:
The trigger isn't a direct user interaction with the Assistant.
You want to display an article automatically using your custom logic.
Note: If you use the standard
article
method (without extra options), it will automatically open the Assistant interface.
Examples
Open an article in the Assistant:
Open an article in the sidebar:
Demo Usage
Use
Assistant('article')
to display an article directly in the Assistant.Add the
mode: 'sidebar'
Option to show the article in a sidebar instead.
Last updated