Table of Contents

How to Use the Dynamic Data Block in Landbot

Abby Updated by Abby

Confused by any terms? We have aย quick reference guideย for beginners.

The Dynamic Data block lets you display interactive, updatable lists in your chatbot - perfect for product catalogs, location selections, or any list that changes over time.

Instead of creating static buttons for every item, you can pull a live list directly from an external database or API.

Quick Start: Array of Strings

Let's build a simple appointment scheduler where users can choose from available time slots.

Example:

Appointment times

Goal:

Show available time slots

Let's say I have the following time slots available for Tuesday: 9am, 11am, 2pm, 4pm

My database (webhook block) would return something like this: ["9:00 AM", "11:00 AM", "2:00 PM", "4:00 PM"] which is an array of strings

When saved the field should look like this:

The next step is to add the Dynamic Data block selecting the STRINGS option

From there we can check if we want to display the data as buttons or autocomplete (cards should be used with arrays of objects which contain images)

Quick Start: Array of Objects

Let's build a catalog of medical professionals to choose from

Example:

Medical Professional

Goal:

Select between available professionals

In the following example we'll be working with an array of objects, each object will contain information about a medical professional

The array of objects will look like this๐Ÿ‘‡ with the information of each professional enclosed in a pair of curly brackets

We'll save the entire response as an array which we'll select in the Dynamic Data block and display as an array of objects

Since we have an image url we can use the card option, next we'll select the paths

P.S. not all fields need to be filled in

Object Paths

In a basic object: [{"Name":"Sarah"}]

The path we use to display "Sarah" would just be Name

However, it's very common to have nested objects. For example:

[{"ID":"23232", "Information":{"Name":"Sarah", "Contact":{"Email":"sarah@email.com"}}}]

Then the paths would be:

- "Sarah" = `Information.Name`

- "sarah@email.com" = `Information.Contact.Email`

Each inner object is accessed with a full stop . and then the name of the key - which should be added exactly as it appears in your object, if it's a lower case letter in your object it should also be lower case in the field

Saving the Index

In the Dynamic Data block there is the option to save the index of the user selection, this should be saved as a numerical value so it can later be used in Formulas blocks to retrieve more information from the object

Arrays are zero indexed, meaning that it starts counting from zero instead of one, the first item in the array - or the first object in the array will be saved as 0

To use it in the formulas block you would need to use the GetValue formula, here's more information

Platform-Specific Views: WhatsApp & Messenger vs. Web

For Dynamic Data in WhatsApp and Messenger bots it's only possible to display the data as buttons

WhatsApp View:

Messenger View:

In web bots there are three different ways to display data:

Display as Buttons:

Display as Cards:

Display as Autocomplete:

Beginner's Reference

Array

A list of items in square brackets [] which could be strings or objects

Array of strings

A list of items in square brackets in string format: ["one", "two", "three"]

String

A piece of information wrapped in quotation marks: "string"

Object

A way to group information: {"name": "Sarah", "age":"22"}

Key-Value Pairs

Inside an object - field name and the field value

Using the above example the key is "name" and the value is "Sarah"

Array of objects

Objects separated by commas: [{"name": "Sarah", "age":"22"}, {"name": "John", "age":"12"}]

Nested object

An object with it's own objects: [{"name":"Sarah","Address":{"street":"1302 Pennsylvania AVE", "postal code": 09029}, "Age":"22"}]

Path

How we access a piece of information in an object

If object = {"name": "Sarah", "age":"22"} then object.name = "Sarah"

Array index

The index is the numerical order of the item in the array in this example ["Red", "Green", "Blue"]

Red is at index 0, Green is at index 1 and Blue is at index 2

Zero Index

Array's start counting at zero, so index zero in this example: ["Red", "Green", "Blue"] is "Red"

FAQs

Can I use Google Sheets as a database?
Yes, but indirectly. Google Sheets does not have a native REST API, so you will need to use a third-party service or a script to convert your sheet into a JSON API that Landbot can call. We recommend using Airtable for a more straightforward setup
Can I avoid displaying duplicate items?
Unfortunately no, the arrays are displayed as they are, so in case you want to display unique values, you should filter the data before it's displayed
Can I add a skip button?
There's no native way to do this, however, you can use the Push formula (in the formula block) to add a 'Skip' item to your array
How can I change the styles of the Dynamic Data block?
If you're familiar with CSS you can check out the classes for this block here
Why does it look different in WhatsApp and Messenger?
WhatsApp and Messenger provide a standard 'template' for message layouts. While Landbot can create card displays and searchable lists within web chats, these platforms only allow basic button formats
Why isn't it recognizing the path?
Be sure you're using the correct notation! The Dynamic Data block doesn't use JavaScript notation, so field[0] would be field.subfield
Why don't I have the option to display as cards or autocomplete?
If your bot is not a web bot you will only have the option to display the data as buttons
What's the maximum size for an array?
1mb or 20,000 characters
Help! It's still not working!
If you have any doubts contact us at help@landbot.io, we're happy to help!

Was this article helpful?

Get the array's index of the user selection and extract information from array

Contact