Skip to main content

How to Add a Drop-Down List to an Adaptive Card

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

When someone has to pick one option from a fixed list, a drop-down keeps the card short. In an Adaptive Card, that's an Input.ChoiceSet: each choice has the text people see and the value your code gets.

Syntax​

Card JSON
{
"type": "Input.ChoiceSet",
"id": "<input id>",
"label": "<label>",
"placeholder": "<text before a choice>",
"choices": [
{ "title": "<text to show>", "value": "<value to send>" }
]
}
PartWhat it does
idThe key the choice is sent under
labelThe text above the list
placeholderThe text in the list before anything is picked
choicesThe options. Each has a title, Text to display., and a value, The raw value for the choice.
styleLeave it out, or set "compact", for a drop-down. "expanded" shows every choice as a radio button instead

Microsoft's Input.ChoiceSet reference adds a condition for the placeholder: Only visible when no selection has been made, the style is compact and isMultiSelect is false.

The Example​

A lunch order card asks What would you like? with three choices. Each shows a full name and sends a short value: Tomato soup sends soup, Caesar salad sends salad, and Cheese sandwich sends sandwich.

Prerequisites​

  • An agent that sends Adaptive Cards in Microsoft Teams and reads what a card's Submit button sends.

Step 1: Write the Card​

Cards/lunch.json
{
"type": "AdaptiveCard",
"version": "1.5",
"body": [
{ "type": "TextBlock", "text": "Lunch order", "size": "Large", "weight": "Bolder" },
{
"type": "Input.ChoiceSet",
"id": "lunch",
"label": "What would you like?",
"placeholder": "Pick a lunch",
"choices": [
{ "title": "Tomato soup", "value": "soup" },
{ "title": "Caesar salad", "value": "salad" },
{ "title": "Cheese sandwich", "value": "sandwich" }
]
}
],
"actions": [
{ "type": "Action.Submit", "title": "Order", "data": { "card": "lunch" } }
]
}

lunch.json in a macOS-style editor window: an Adaptive Card with a Lunch order title, an Input.ChoiceSet with id lunch, label What would you like?, placeholder Pick a lunch and three choices with titles and short values, and an Order button

There's no style, so the list is a drop-down, the default.

Step 2: Pick a Lunch in Teams​

Send the card from your agent, as How to Send an Adaptive Card in the Microsoft 365 Agents SDK in C# shows. In Teams:

The Lunch order card in Teams: What would you like? above a drop-down showing Pick a lunch, and an Order button

Select the list to open it:

The same card with the drop-down open, listing Tomato soup, Caesar salad and Cheese sandwich

Step 3: See What the Card Sends​

Pick Caesar salad and select Order. The agent for this post replies with the values it receives:

The card with Caesar salad picked and Teams' note Your response was sent to the app, and below it the agent's reply The card sent: card lunch, lunch salad

What the agent received
{"card":"lunch","lunch":"salad"}

The card sent the choice's value, salad, under the input's id, lunch, next to the button's own data. The title, Caesar salad, stays on the screen.

Common Mistakes​

MistakeWhat happensDo this instead
Reading the title in the agentThe agent gets the value, not the titleMatch on the values
Using the displayed text as the valueRenaming a choice breaks the code that reads itKeep short, fixed values
Setting "style": "expanded" for a long listEvery choice becomes a radio button on the cardKeep the drop-down for long lists

Troubleshooting​

SymptomLikely causeFix
The placeholder doesn't showA choice is already selected, or the style isn't compactLeave value out, and the style compact

FAQ​

Can people pick more than one?​

With "isMultiSelect": true. The schema then sends the picked values in one string, separated by commas, which is why it says not to put a comma in a value: a ChoiceSet with isMultiSelect set to true returns a comma-delimited string of choice values.

Can the list start with a choice picked?​

Yes: set value to that choice's value, as in How to Prefill the Inputs of an Adaptive Card.

Conclusion​

A drop-down in an Adaptive Card is an Input.ChoiceSet in the compact style, the default: choices with a title to show and a value to send, and a placeholder until something is picked. Your agent gets the picked value under the input's id.

Additional Resources​