Skip to main content
To enable Crescendo.ai AI Assistant on your WebSite, we provide Bot Widget that can be quickly added to your site. You can use simple embed code to enable Bot. You can also customize appearance of the bot widget, by passing parameters and configuring CSS variables.
Note: Place this embed code at the end of the <body> tag.
This ensures the DOM is fully loaded before the script runs, prevents “reference before definition” errors.

Bot Widget embed code

Here is an example embed code you would need to add to your website to enable Bot:

Bot Widget parameters

You can pass the following parameters to Bot Widget: Here is an example how to customize logo:
Here is an example of how to customize the popup logo:

Customizing appearance

You can use CSS variables to customize appearance of certain elements of the Bot Widget. Here is the list of supported CSS variables: Here is an example how to use CSS variables:

Pre-filled Form Fields Values

Bot may show a form to collect data from the user. For example, to collect contact information, such as name, email and phone number. At the same time, these values may already be known in the web application, for example, in case when user is already authenticated. It would be redundant to ask user to enter this data again in the bot. For such situations, Bot provides possibility to specify pre-filled values for the form fields. You may do so by passing values in a Bot attribute prefilled-form-fields or by calling method setPrefilledFormFields :::info When pre-filled form field values are provided, Bot will still show the form, initially filled with these values. This allows user to double-check that the information is correct, and make any adjustments if necessary before submitting the form.
:::
Pre-filled form fields should be an object, where keys are form field names, and values are form field values. For example:

Set pre-filled form fields via attribute value

Set value of the Bot widget attribute prefilled-form-fields to JSON representation of the object with form fields:
:::info The value of the attribute must be properly formatted JSON. :::

Set pre-filled form fields using method call

You may need to make an API call to your backend to get the data for pre-filled form fields. For these cases, use method setPrefilledFormFields to set the data when it becomes available.

Full example

Here is a full example setting pre-filled form fields using data from URL query string

Anchor button

Position Anchor button

You may position Bot Widget Anchor button anywhere on the screen, using css.
For example:
If you change default position of the anchor button, you may also need to adjust position of the popup message relative to the anchor button. For this, set appropriate value for --enegelai-bot-anchor-popup-position CSS variable.

Hide Anchor button

Sometimes you may need to hide anchor button, for example when Bot Widget should always stay open. It’s possible to do by adding this to style:

Bot Widget Javascript API

You can call Bot Widget methods from your Javascript code to control Bot Widget programmatically.

setOpen

Allows you to open or close the Bot Widget programmatically.

Parameters

  • state (boolean): Pass true to open the Bot Widget, or false to close it.

Example

getOpen

Returns current Bot Widget open state. Returns true if Bot Widget is open, and false if it is closed.

Example

toggleOpen

Toggles Bot Widget open state. Opens it if it closed, closes it if it is open.

Example

setPrefilledFormFields

Allows you to pre-fill form fields values programmatically, for example, when they are known in advance, or retrieved from your backend.

Parameters

  • data (object): Object with form field names as keys, and form field values as values.

Example

clearConversation

Clears current Bot conversation and starts new one.

Example

setInputValue

Allows you to set the value of the input field in the Bot Widget. You can use this method to set suggested message in the bot input field, for example, based on how user navigates on your website.

Parameters

  • value (string): Text to set as value of input field. Pass empty string as value to clear the input field.

Example

setContext

Allows you to pass information about user to the Bot, so Bot can use this information in answers. You can use this method to pass information like user name, what is user currently looking at one the website (e.g., current product page), or any other information that may be useful for the Bot to provide better answers.

Parameters

  • data (object): Javascript object with data. Give keys self-explanatory names, so the Bot can understand better what information this is and how it can be used.

Example

sendMessage

Allows you to send message in the bot conversation. You can use this method to send some predefined messages when user clicks some button on the page, for example.

Parameters

  • text (string): Message to send.

Example

Bot Widget Events

You can subscribe to the events Bot Widget emits during chat processing. This can be useful to track bot conversation state and user activities in the bot widget. You can also use information from the Bot Widget events to send data to your backend for further processing.

c7o:bot:conversationStart

Event “c7o:bot:conversationStart” is emitted when user starts conversation with the bot by sending the first message. Expect object with the following information in the event.detail:

c7o:bot:open

Event “c7o:bot:open” is emitted when user opens the bot widget.

c7o:bot:close

Event “c7o:bot:close” is emitted when user closes the bot widget.

c7o:bot:formSubmit

Event “c7o:bot:formSubmit” is emitted when user submits the form with contact information before being connected to the agent. Expect object with form data in the event.detail:

Example