ThriveDesk Developer Hub
Help CenterSupportGo to website
  • Assistant
    • Assistant for Web
      • Installation
      • JavaScript API
Powered by GitBook
On this page
  • Assistant('init', assistantId)
  • Assistant('trigger-less-init', assistantId)
  • Assistant('triggerLess')
  • Assistant('open')
  • Assistant('close')
  • Assistant('toggle')
  • Assistant('chat')
  • Assistant('contact')
  • Assistant('order-status')
  • Assistant('identify', userObject)
  • Assistant('article')
  1. Assistant
  2. Assistant for Web

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.

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:

Assistant('article', 'ARTICLE_ID');

<a href="#" onclick="Assistant('article', 'ARTICLE_ID')"></a>

Open an article in the sidebar:

Assistant('article', {
  articleId: 'ARTICLE_ID',
  mode: 'sidebar'
});

<a href="#" onclick="Assistant('article', {
    articleId: 'ARTICLE_ID',
    mode: 'sidebar'
    })" ></a>

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.

PreviousInstallation

Last updated 3 days ago