How to "send" a user to a specific point in the flow with Javascript and with the API

Ana Updated by Ana

In some occasions, we might want to redirect the user to a specific step in the flow. Maybe triggered with an action (onclick) in the website where the bot is embedded or maybe trigger it with the API because an action has been completed.

Here are three examples of how to do it:

1. With onclick in parent page "Send" a user to a specific point in the flow with Javascript while the bot is open

In Landbot 3

In this case we want that the user to click on a button while the bot is open (livechat, embed or pop up types)

Here is the sample set up inside in the builder:

1. We will use Global Keywords, to set up the flows where we want to redirect the user.

Note: Take note of the order of the options, as will be used in the snippet in the parent page

2. Now in the parent page, we need to set up the event listener to trigger with Javascript, and we will add the trigger that will tell the bot to move:

myLandbot.onLoad(function(){

document.getElementsByClassName("openbot")[0].addEventListener("click", function(event){
event.preventDefault()
myLandbot.sendMessage({ type: 'button', message: 'Go to Step 1', payload: '#1' })
});

As you can see payload #1 refers to the first option in the Global Keywords

Here is an example:

How did we do?

Modifying Embed Size

Contact