Table of Contents

Code block

Pau Sanchez Updated by Pau Sanchez

For Landbot (Web)

To see how to deal with Landbot variables and Javascript variables, please check this article

Learn how to use our block type Code, it lets you easily add JavaScript code within a block and trigger Easter eggs!

Sometimes we want to trigger some Javascript functions during the flow, here is where we can do it.

The code in these blocks will be active only when the visitor passes through this point. So functions in the block don't have a global scope:

Warning: the URL must be an HTTPS:// otherwise you will get an error that will not allow you to save changes.
How to use the Code block

This code will be embedded inside <script> </script> tags, so there is no need to add them, as you can see below. In this example, when the visitor passes through this block, a "hello world" will be printed in the console

Code block and Add JS (Custom scripts) [Design/Advanced section]

Code in the Add JS section, are global, as soon as the footer of the bot is loaded in the web, it is ready to use. This is the place to set up, "global" functions and variables with global scope.

Even if they are placed in different sections, code can communicate easily as you can see below. Using the Code blocks to trigger the global

A Google Sheet integration block cannot be located after a Code block

For WhatsApp

For a list of all the blocks and current functionalities with WhatsApp bots, please check here

This block/functionality is not compatible with WhatsApp

For Facebook Messenger

This block/functionality is not compatible with Messenger

How did we do?

AB Test

Conditions block

Contact