Skip to content

JS Widget SDK

The widget SDK allows you to run the Botsquad chat widget on your site.

Installation

When you want to embed the BotSquad bot into your own site, you need to add a bit of Javascript to your site. Just above the closing </body> tag place the following tag:

<script data-botsquad='{"id":"1adc3f20-32e9-4376-a147-d9ef23ac8a4c"}' src="https://bsqd.me/js/widget.js"></script>

where id is the id of your bot. You will also find this script tag in the Connect section of the studio.

Configuration

Most settings that deal with the layout of the widget are configurable from the studio and cannot be specified from Javascript.

API

Once loaded the SDK exposes a global BotSqd object which has the following functions:

BotSqd.event(name, payload)

Send an event to the chat. The chat window needs to be opened already.

BotSqd.openChat()

Open the chat widgets when it was closed.

BotSqd.closeChat()

Closes the chat widget when it was open.

BotSqd.setUserId(id)

Set the user ID that is to be used in the chat. This will re-open the chat window when the user id changes. When the widget it still closed, nothing happens.

BotSqd.getUserId()

Retrieve the current user id that will be sent to Botsquad.