Smartly.AI

Webchat Controls

Our custom webchat come with some controls, depending on your needs, you can go for the synchronous or asynchronous way.

Synchronous controls

Synchronous controls are powerful and can act on real time with your webchat,
their drawback is that they can only work when the SmartlyWebchat library is fully loaded in your website.

// Open the chat widget
SmartlyWebchat.openWidget(); 
// Close the chat widget
SmartlyWebchat.closeWidget();
// Hide the chat widget
SmartlyWebchat.hideWidget();
// Show the chat widget
SmartlyWebchat.showWidget();
// The webchat will show a specific bot message on the webchat
SmartlyWebchat.showBotMessage('I am the bot');
// Same as below but after a certain delay, in ms
SmartlyWebchat.showBotMessage('I am the bot',5000);
// The webchat will send a message to the API on behalf of the user
SmartlyWebchat.sendUserMessage('I am the user');
// Same as below but after a certain delay, in ms
SmartlyWebchat.sendUserMessage('I am the user',5000);

Wait for `SmartlyWebchat` to be loaded

Before using SmartlyWebchat library you will have to wait for it to be fully loaded in your web page

Asynchronous controls

Asynchronous controls always works, even if the library is not yet fully loaded,
their only drawback is that they can't be used in real time.

1. Hide the webchat on certain pages

// Hide the webchat on this page
var SMARTLY_HIDE_WEBCHAT = true;

2. Open the webchat with a specific message after a certain delay

First, here is a code snippet to show a simple text message after 5s

// Simple text message to be shown after 5 seconds
var message =  "hello";
var SMARTLY_BOT_SEND_MESSAGE = message;
var SMARTLY_BOT_SEND_MESSAGE_TIMEOUT = 5000;

Second, here is a code snippet to send a message with quick replies after 5s

// Rich message to be shown after 5 seconds
var message = ' [{"quick_replies": [{"content_type": "text","title": "Besoin d aide","payload": "Jai besoin daide pour aller mieux"},{"content_type": "text","title": "Venir à  C. Perrens","payload": "comment venir à charles perrens"}],"text": " Choisissez un sujet ou écrivez directement votre question et laissez-vous guider."}]';
var SMARTLY_BOT_SEND_MESSAGE = message;
var SMARTLY_BOT_SEND_MESSAGE_TIMEOUT = 5000;

Easy to use

This method will always work

Updated a day ago

Webchat Controls


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.