1. Home
  2. Webhooks & APIs
  3. How to Open and Close the Chat Window via API
  • User Guide
  • Developer Docs
Frequently visited sections What is verloop?, FAQ Overview?

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.io 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 > Chat > Installation or directly go to

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

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

Use the code snippet to install Verloop

To open the 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.io 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.io APIs for controlling the livechat widget.

Updated on September 1, 2023

Was this article helpful?

Related Articles

Schedule a demo

Get Started with Verloop.io