Your Botnation web chatbot can now interact with the web site it belongs to (at least, the website where it's set up). The web chatbot can now interact with your web site through events you may intercept in order to add a product to your cart, change a page without opening a new website and so on.

Disclaimer : This document is not covered by Botnation support. Botnation sends a Javascript event to the browser and displays your website. Any interpretation or action linked to those events doesn't imply Botnation. Those web developments on your site may interact with other apps (analytics, cart, payment...) Botnation did not work on. If you encounter any trouble, we strongly advise you to contact a Javascript programmer. The Javascript's code will be applied to your website, not to your chatbot. For instance, your logo was made by a graphic designer, not by Botnation. The same principle applies here !

How to send informations directly from your chatbot to your website

On your Botnation's dashboard, you'll have to activate the feature "Javascript Event" :

Create a Chatbot for a Website

Then, name the event that will be intercepted through this name on your website. If needed, you may add extra set up which will be taken back under a key/value on your website. Those set ups may be composed with Botnation variables.

Build a Chatbot for a Website

Those set up may be useful to set up an event when an item is added to a cart by simply communicating a client ID and a product reference.

There's not limit : you can add as many event as necessary from any section in your chatbot. Onlyne one script might be enough on your website to intercept them.

How to set up a Javascript event on your side

On your website, just add an "onEvents" in the Botnation Javascript tag that displays the chatbot (we insiste on the "in").

Example :

window.chatboxSettings = {
onEvents: function(eventName, eventArgs) {
// votre action
// eventName = "le nom de l'évènement"
// eventArgs = {arg1: "val1", arg2: "val2"}
}
}

For instance, if you want the chatbot to communicate a page change to your chatbot user's browser :

onEvents: function (eventName, eventArgs) {
switch (eventName) {
case 'redirection':
// verify that we received an url
if (eventArgs.hasOwnProperty('url')) {
// redirect to the url
window.location.href = eventArgs.url;
}
break;
default:
break;
}
}

Also, you have the possibility to redirect the user to an external website by signaling a full address as for instance : https://www.example.com/my-redirect-page or toward another page of your current website by using a related page, example : /my-redirect-page. Your pages' URL must start by a slash ('/').

Once the set up done, launch your new redirections from the desired section of your chatbot without modifying the page's script. You only have to repeat the steps by strictly respecting the event name and the set up name.

Make it easier

If you do several actions on the event name only - and not on the event's values, you'll have to define a "case" for this one :

window.chatboxSettings = {

// ensemble du tag Botnation

// Communication Events

onEvents: function (eventName, eventArgs) {

switch (eventName) {

case 'riri':

// votre action javascript

break;

case 'fifi':

// votre action javascript

break;

case 'loulou':

// votre action javascript

break;

default:

break;

}

}

}

This feature is limitless and enables you to pilot the user's browser and any other Javascript apps included.

If you use Google Tag Manager on your website or any other tag management tool, it should be suitable.

Disclaimer : Javascript events are managed on your side, on your own website, then, they won't work on Botnation's test page or on Chatbotnation as you won't be able to edit the sites' code.

To make Javascript events available, you'll first have to publish your chatbot on your own website.

Please send us your best project so as we can put them forward !

Next steps :

Did this answer your question?