Dynamic Options Display Through API Call in MSG91 Bot
Introduction
Dynamic options in a chatbot allow you to fetch and display real-time data to users based on their selections, rather than relying on static options. This makes the bot more intelligent, interactive, and personalized, creating a smoother user experience. By dynamically fetching options via an API call, you can handle a wide range of use cases — from country → state selections to product catalogs — without manually updating the bot.
This approach is a game changer for chatbots:
Users see only relevant, up-to-date options.
It reduces manual maintenance and errors.
It enables more complex conversational flows with minimal effort.
In this guide, we’ll demonstrate how to implement dynamic option display in MSG91 by letting users select a country (India, USA, China) and fetching 5 corresponding states through an API call.
Step 1: Create a Dummy Bot

Go to the MSG91 Bot panel.
Create a new bot named “Country → State Selector”.
Add the first message card:
Message: “Select a country:”
Options: India, USA, China
Save the user response in a variable:
country_selected
Step 2: Set Up API Call Using Plugin Node
Refer to the image attached


Add a Plugin node from the Connections section to call a dummy API that fetches random states for the selected country.
Alternatively, you can use an API node for the same task.
Once you click Get Response, you can view the API response

Save the entire response in a variable named:
statesVariable type: Array
Drag a Message Card and select List type for the body content.
Configure Dynamic Option Buttons:
Select Variable:
states(this stores the API response in array format)JSON Path for Title:
state(each object in the array has the keystatestoring the state name)Description: Skip this since we don’t have any description field.
Step 3: Display Dynamic Options
When the user sees the message card, they will now see 5 dynamic options corresponding to the selected country.
Save the user selection in a variable:
state_selected
Step 4: Iteration and Refresh
Every time a new country is selected, make a fresh API call.
Ensure
statesoverwrites the previous response.Always maintain the format as array of objects with key
state.
Step 5: Using the Selected State

Use
state_selectedfor further logic or API calls.
Example:"You selected {{state_selected}} from {{country_selected}}."
5. Output
Everytime user selects a country the bot fetches API response and display it to the end user


For any further queries you can reach out to us at support@msg91.com