Categories

Categories

Trigger chatbot from a Link or Button

Trigger chatbot from a Link or Button

Here is a quick demo.

Steps Involved

1. Disable the default launcher
Please go to your bot Settings page. Under Behavior, set Widget Button as Custom Button Only
 
notion image
 
Now the default launcher with the avatar will be hidden. You have to create a new button or link to your webpage to open the chatbot widget.
 
2. Add the following snippet to your webpage to open the widget using a button
<button onclick="collectchat.open()">Open Chat</button>
 
Alternatively, following JavaScript methods can be used to customise bot behaviour
  • collectchat.close() : Closes the widget
  • collectchat.toggle() : Open or close the bot based on existing state
 
If it is a link, then use the following snippet:
<a href="#" onclick="collectchat.open()">Open Chat</a>
 
Note
Make sure to add the snippet code of the chatbot on the same page where you are calling the collectchat.open() method. If the snippet code is not present, these Javascript methods will not function.
 
Tip
If you pass the Bot ID to this function, then you can call a different bot on the click of the button. Example:
<a href="#" onclick="collectchat.open('BOTID')">Open new bot</a>


Still need help?

Contact us