1. Home
  2. Developers
  3. How to open and close the chat window via API

How to open and close the chat window via API

If you’d like to open the chat window without having to manually click the bot, you can set the bot to open automatically.


Before you begin tweaking your bot, you’ll have to install Verloop on your website.

When you log into your account for the first time you will receive a snippet for the chat widget. You can always go back to this snipped from Settings → Installation or directly go to

<yourcompanyname>.verloop.io/admin/settings/installation

Add this snippet to every web page where you’d like the Verloop chatbot to work. Copy and paste it right before the </body> tag on each of your web page.

Use the code snippet to install Verloop
Use the code snippet to install Verloop

 

To open chat widget, insert the following API right below your script.

Verloop(function() {
    this.openWidget();
});

Keep in mind that when a recipe is activated in a particular session, it can’t be changed. If no recipe has been selected, the bot runs the default recipe that was set. You can set the default in the recipe tab of the Verloop admin dashboard.

Alternatively, you can also close the chat widget by using the following script.

Verloop(function() {
    this.closeWidget();
});

You can call this “close widget” script at any point you’d like, based on your preferences and depending on the use case of the bot.


Alongside opening and closing the widget using the aforementioned script, there are also ways to ensure the widget doesn’t show up at all. There is a detailed article which has details of all the Verloop APIs for controlling livechat widget.

Was this article helpful?

Related Articles