# Trigger your chatbot from a Link or Button

Here is a quick demo [https://demos.collect.chat/custom-button-for-chatbot].


DISABLE THE DEFAULT LAUNCHER

Please go to your chatbot Settings and under Behaviour, set Widget
button as Custom button only



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.




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
[https://developers.collect.chat/#/methods] can be used to customize chatbot
behavior

 * collectchat.close() : Closes the widget
   
   

 * collectchat.toggle() : Open or close the chatbot 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 load a different chatbot
on the click of the button. Example:

<a href="#" onclick="collectchat.open('BOTID')">Open new bot</a>