Using Dynamic Carousel feature for Messenger and IG Chatbots
In this article, you'll learn to use dynamic carousel feature for chatbots.
Go to Facebook & Instagram > Chatbot Flow Builder
Create New Messenger Flow > Enter Flow Name > Add a dynamic carousel element
Configuring dynamic element
Step 1: Choosing the Data Source
Step 2: Configuring Data Source
Step 3: Assigning Source Array
Step 4: Assigning Carousel Item Values
Choosing Data Source: Click on the dynamic carousel element > Choose Data Source (Google Sheet / HTTP Request) > Next
Configuring Data Source: Enter the request URL and parameters > Test Request
In this, I'm using movies API for show you the demo.
Assigning Source Array: Click on the Map Response button and check the response
Assigning Carousel Item Values: Assign values by using custom variables > Confirm
Adding a Keyword Trigger
We have configured a dynamic carousel element. Let's add a keyword trigger and test.
Add a keyword Element in the interface
Enter keyword > select match type and OK
Adding a "No Values Found" Message
Add a text element > Enter Message
Making Quick Replies Dynamic
Add quick replies to the dynamic carousel element
Click on Create Custom Variable
Enter variable name > fallback value and Save
Click on the dynamic carousel element > Go to step 2: Configure Data Source > Change Page value > Test Request
Add a Function element
Click on the function element > clear the existing codes and Add JavaScript code
let page = Number({{movie_page_value}}) + 1 return page;
Add a new function element for "back" > clear the existing codes and Add JavaScript code
let page = Number({{movie_page_value}}) + 1; return page < 1 ? 1 : page;
Re-route the function's next step to the dynamic carousel element and save
For Next & Back Label(Dynamic): Click on Create Custom Variable > Enter Variable Name > Enter Fallback Value
Update the Label Value: Go to Utilities > Custom Variables > Edit > Update label and save
Go to chatbot flow builder > Add a function element (for the dynamic label) > Enter Javascript code
let page = Number({{movie_page_value}}); let limit = 20; let before = page * limit; let after = (page + 1) * limit; return `Next ${before} - ${after}`
Save Output To Custom Variable "Next" and Save
Repeat the same for the Back label
let page = Number({{movie_page_value}}); let limit = 20; let before = (page - 1) * limit; let after = page * limit; return `Back ${before} - ${after}`
Save output to the custom variable "Back" and Save
Connect the nodes as displayed below
Testing the Flow
Go to Messenger > Send Trigger Keyword and test the flow.