Initialization

The standard initialization script for your web chatbot can be copied directly from the "How To Embed" tab inside the Web Channel publishing dialog. The script is already configured for your chatbot and will look like this one below:

<script [...] src="https://res.xenioo.com/plugin/xenioo.js"></script>
<script>
    xenioowebchat.Start("<API Token>");
</script>

This is the barebone initialization process: all the configuration will be read from your publish settings and nothing else is needed.

Advanced Initialization

The following sections will show how you can go much further with Xenioo initialization to significantly manipulate how the chatbot is initialized and settings are used.

Changing initialization settings

The initialization call can be modified to supply one or more initialization parameter that will override the settings you've specified in the Web Publishing Dialog. As an example, you could change the chatbot widget appearance delay like this:

<script [...] src="https://res.xenioo.com/plugin/xenioo.js"></script>
<script>
    xenioowebchat.Start("39b71741-1a09-45eb-86e4-f0c90b547d9d", {
            appeardelay:5
        }
    );
</script>

The above script will make the chat widget appear after 5 seconds. This parameter will automatically override the delay parameter you've specified in the Web Publishing Dialog settings.

You can of course add multiple settings like in the script below:

<script [...] src="https://res.xenioo.com/plugin/xenioo.js"></script>
<script>
    xenioowebchat.Start("<API Token>", {
            appeardelay:5,
            subtitle: 'Hello from Xenioo!!'
        }
    );
</script>

Use the table below as a general reference for all the initialization parameters you can override:

Initializing with Variables and Tags

Different pages on your website may need different variables or tags to be supplied to your chatbot. As an example, you could have your chatbot receive specific campaign parameters so that it can track users coming from specific ad. To do so, you supply variables or tags directly inside the initialization script. In the following example, we're sending the variable test:

<script [...] src="https://res.xenioo.com/plugin/xenioo.js"></script>
<script>
    xenioowebchat.Start("<API Token>", {
          variables:[
            { Name:"test", Value:"this is the value" }
          ]
        }
    );
</script>

In a very similar way, you can supply one or more tags:

<script [...] src="https://res.xenioo.com/plugin/xenioo.js"></script>
<script>
    xenioowebchat.Start("<chatbotid>", {
          tags:[
            "VIP_USER",
            "FROM_GOOGLE_AD"
          ]
        }
    );
</script>

Both variables and tags will be made available to your chatbot from the very start and can be used immediately in your flow.

Starting from a specific behavior

If you want your chatbot to start from a specific behavior you can set the corresponding API token directly in the initialization script:

<script [...] src="https://res.xenioo.com/plugin/xenioo.js"></script>
<script>
    xenioowebchat.Start("<chatbotid>", {
          behaviour: "<YOUR BEHAVIOUR API TOKEN>"
        }
    );
</script>

This setting will override the default start behavior and change the default flow. This setting is particularly useful if you have multiple pages on your website and want your chatbot to start addressing the user differently depending on the location.

Last updated