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

Assistant('init', 'YOUR_ASSISTANT_ID_HERE');

Example use case:

<a href="#" onclick="Assistant('init', 'YOUR_ASSISTANT_ID_HERE')"></a>

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.

Assistant('trigger-less-init', 'YOUR_ASSISTANT_ID_HERE');

Example use case:

<a href="#" onclick="Assistant('trigger-less-init', 'YOUR_ASSISTANT_ID_HERE')"></a>

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.

Assistant('triggerLess');

Example use case:

<a href="#" onclick="Assistant('triggerLess')"></a>

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

Assistant('open');

Example use case:

<a href="#" onclick="Assistant('open')"></a>

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

Assistant('close');

Example use case:

<a href="#" onclick="Assistant('close')"></a>

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

Assistant('toggle');

Example use case:

<a href="#" onclick="Assistant('toggle')"></a>

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.

Assistant('chat');

Example use case:

<a href="#" onclick="Assistant('chat')"></a>

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.

Assistant('contact', {
    subject: 'Issue title',
    body: 'Issue details',
});

Example use case:

<a href="#" onclick="Assistant('contact', {
    subject: 'Issue title',
    body: 'Issue details',
})"></a>

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.

Assistant('order-status');

Example use case:

<a href="#" onclick="Assistant('order-status')"></a>

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.

Assistant('identify', {
  name: 'Parvez Akhter',
  email: 'demo@email.com',
});

Example use case:

<a href="#" onclick="Assistant('identify', {
  name: 'Parvez Akhter',
  email: 'demo@email.com',
})"></a>

N.B You can use this any way you want with your own logic and everything.

Last updated