Table of Contents
Code block
Updated
by Pau Sanchez
For Landbot (Web)
Learn how to use our block type Code, it lets you easily add JavaScript code within a block!

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:

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) and CSS
Code in the Add JS section, are global, as soon as the footer of the bot is loaded on 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

Limitations
- A Google Sheet integration block cannot be located after a Code block.
- Is not possible to test or use the Code block on the Sandbox plan.
For WhatsApp
This block/functionality is not compatible with WhatsApp
For Facebook Messenger
This block/functionality is not compatible with Messenger