Changing the starting block
There are many situations where you might want to show a different message to the user when they start a conversation. For example, this might be on a particular day of the week, or based on the page they are currently viewing. Both IntelAgent and the chat widget support this use case and enabling it is very simple.
Just as you would pass other Configuration options, there is a startBlock
option which can be set to change the initial block sent to a user. This can be used as follows :
window.addEventListener('wbb_plugin_loaded', function(event) {
new window.WBBChatPlugin({
// Other settings here...
// Starting Block
startBlock: getQueryParam("startBlock") || "intro",
// more settings as required...
});
});
The startBlock
parameter shown is either the Block ID
of the block you wish to trigger or the title
of the block.

In this example, setting startBlock
to either 5c62ead3ab358c3780bb60dc or intro
will trigger the same block.
Conditional logic
While there may be lots of scenarios where you want to trigger different blocks, one such example might be based on the URL the user is currently on. The following example will show you how to add some code to the way you load the widget so that you will get a different block each time.
window.addEventListener('wbb_plugin_loaded', function(event) {
const NEW_USER = "intro";
const LOCAL_GOV = "5d83816be584e656e7b86eeb";
const UTILITIES = "5fa126d6b0622f3854fa8148";
let startBlockID = NEW_USER;
if ( document.location.pathname == "/government" ) {
startBlockID = LOCAL_GOV;
}
if ( document.location.pathname == "/utilities" ) {
startBlockID = UTILITIES;
}
new window.WBBChatPlugin({
// Other settings here...
// Starting block
startBlock: getQueryParam("startBlock") || startBlockID,
// more settings as required...
});
});
Note that by using the getQueryParam
option as well we can also allow the starting block to be changed based on the URL the user has clicked on. For example, the following URL could open a page and specify a specific block to load.
https://www.wbb.ai/utilities?startBlock=5fa126d6b0622f3854fa8148
Last updated