Trigger a Global Keyword with JS (web v3)

Pau Sanchez Updated by Pau Sanchez

Global Keywords allows you to set paths, based on a specific Keyword. Thanks to Landbot SDK we can trigger a Message via Javascript, that can trigger the sending of a message, that will trigger the global Keyword and redirect the use to the specific step

To know more about Global keywords, please check this

Order of actions:

  1. Code block triggers function
  2. Function triggers SDK
  3. SDK sends message with keyword
  4. Global Keyword Triggered
  5. Flow redirected

Flow in the builder:

In the bot:

  1. We need to set up the function that will trigger the SDK sending message:

let landbotScope = this;
this.onLoad(function() {
landbotScope.window.messageUser = function() {
landbotScope.sendMessage({ type: 'button', message: 'welcome'})

Note, you can customise the input to be sent. In the example above we send the keyword "welcome"

  1. To trigger the "messageUser" function we just create, we will add a Code block with the following code:

Obviously you can pass variables from the bot:


It's important that this code block is not connected after with any other block, or the messages will be displayed without order

How did we do?

Launching a bot depending on browser language

Create a Scale out of Buttons - Workaround