Table of Contents
Trigger a Global Keyword with JS (web v3)
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:
- Code block triggers function
- Function triggers SDK
- SDK sends message with keyword
- Global Keyword Triggered
- Flow redirected
Flow in the builder:

In the bot:

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

<script>
let landbotScope = this;
this.onLoad(function() {
landbotScope.window.messageUser = function() {
landbotScope.sendMessage({ type: 'button', message: 'welcome'})
}
});
</script>
Note, you can customise the input to be sent. In the example above we send the keyword "welcome"
- To trigger the "messageUser" function we just create, we will add a Code block with the following code:

this.window.messageUser()
Obviously you can pass variables from the bot:
this.window.messageUser('@{variable}')It's important that this code block is not connected after with any other block, or the messages will be displayed without order