How to display an HTML Table in Landbot v3 web

Pau Sanchez Updated by Pau Sanchez

Dynamic Data block is great to display an array of options that needs to be selected. But we might need to simply display a table with data coming from an array, probably from a request (Webhook).

Here is an example of how to do it and display an array like this:


And display it in the bot like this (Here is the example:

We will be based on this flow

Here is how it can be done:

  1. In the Set Variable, we create a Variable type array, similar to what you are getting from the Webhook:

  1. In the Next step is to create the HTML code that we will store in a Landbot variables, so we can display it later, just by using that variable:

Here is the code:

let myArray = @array;
let table = '<table><tr><th>Item</th><th>Price</th></tr>';
    for (let i = 0; i < myArray.length; i++) {
        let row = `<tr>
table = table + row;
    table += '</table>';
this.setCustomData({tablehtml: table});

You will need to adapt the headers and the keys from your array to your needs

  1. As you can see in the last line, we set up to a Landbot variable called "tablehtml" the value of the HTML to display the table.4. Before we show the variable, we need a user input, that is why we use the buttons block (that step cannot be avoided)

How did we do?

How to let user select a time of booking (with a minimum 45 minutes notice)

How to Perform Basic Calculations