In the web chat, through the SDK library, events can be executed that allow developers to perform various actions within the chat window in an HTML page, where the chat is embedded.
Some examples are, opening and minimizing the chat window, initializing properties of the user that is interacting with it, sending a message/query to the bot (so that it responds).
In addition, it is also possible to subscribe to a series of events that will be triggered after the user interacts with the chat window, such as measuring own data each time a user clicks the start button.
Important: It is recommended that developers read and use this documentation.
To use events from the SDK, it is recommended to call the ready method of the $aivo object: $aivo.ready(function() { ... });
This will work as a callback and will fire, immediately after finishing the initial window configurations, the events inside the function passed by parameter.
Below is an example of what the callback would look like.
// include script without async attribute <script type="text/javascript" src="https://cdn.agentbot.net/core/{your_channel_token}.js" charset="UTF-8"></script> <script type="text/javascript"> $aivo.ready(function() { $aivo.user.set("name", "John Doe"); $aivo.user.set("device", "iPhone"); $aivo.chat.open(); $aivo.chat.addMessage("Welcome, how can I help you?"); }); </script> |
Find out here all the events and actions carried out by each one of them.