Skip to main content

How to Add a Multi-Line Text Box to an Adaptive Card

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

A one-line box is fine for a name, but feedback and notes need room. An Adaptive Card Input.Text becomes a taller box that takes several lines when you set isMultiline, and maxLength keeps the answer to a size your agent can handle.

Syntax​

Card JSON
{
"type": "Input.Text",
"id": "<input id>",
"label": "<label>",
"isMultiline": true,
"maxLength": <most characters>,
"placeholder": "<hint shown while it's empty>"
}
PartWhat it does
isMultilineIf true, allow multiple lines of input.
maxLengthHint of maximum length characters to collect (may be ignored by some clients).
placeholderDescription of the input desired. Displayed when no text has been input.

The descriptions are from Microsoft's Input.Text reference.

The Example​

A training feedback card asks What should we change? in a multi-line box of up to 300 characters, with Up to 300 characters as its placeholder.

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/feedback.json
{
"type": "AdaptiveCard",
"version": "1.5",
"body": [
{ "type": "TextBlock", "text": "Training feedback", "size": "Large", "weight": "Bolder" },
{
"type": "Input.Text",
"id": "comments",
"label": "What should we change?",
"isMultiline": true,
"maxLength": 300,
"placeholder": "Up to 300 characters"
}
],
"actions": [
{ "type": "Action.Submit", "title": "Send", "data": { "card": "feedback" } }
]
}

feedback.json in a macOS-style editor window: an Adaptive Card with a Training feedback title, an Input.Text with id comments, label What should we change?, isMultiline true, maxLength 300 and placeholder Up to 300 characters, and a Send button

Step 2: Type Two Lines in Teams​

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

The Training feedback card in Teams: What should we change? above a tall empty box showing Up to 300 characters, and a Send button

Type a line, press Enter, and type a second one. In a multi-line box, Enter starts a new line instead of sending:

The same card with two lines in the box: More practice time, please. and The room was too warm.

Step 3: Send It​

Select Send. The agent for this post replies with the values it receives:

The card with Teams' note Your response was sent to the app, and below it the agent's reply The card sent: card feedback, comments More practice time, please. backslash n The room was too warm.

What the agent received
{"card":"feedback","comments":"More practice time, please.\nThe room was too warm."}

The line break arrived as \n, a newline in the JSON string. When the agent shows the text again, in a card or a message, it can keep or replace those line breaks.

What maxLength Did in Teams​

On a fresh card, I typed 310 characters into the box. It stopped taking them at 300: the text box in Teams carries the limit itself, as an HTML maxlength of 300, so the card never had more to send.

Common Mistakes​

MistakeWhat happensDo this instead
No isMultiline for long answersA one-line boxSet "isMultiline": true
Trusting maxLength aloneIt's a hint, and other apps may not enforce itCheck the length in the agent too
Treating \n as two charactersIt's one newline character in the stringSplit or replace on \n

Troubleshooting​

SymptomLikely causeFix
Typing stops before the endThe box reached maxLengthRaise maxLength, or say the limit in the placeholder

FAQ​

Can I prefill a multi-line box?​

Yes, with value, as for any text box: How to Prefill the Inputs of an Adaptive Card.

Can I require an answer?​

Yes, with "isRequired": true and an errorMessage: How to Make Adaptive Card Inputs Required.

Conclusion​

For longer answers, give an Input.Text "isMultiline": true, a maxLength and a placeholder that says the limit. In Teams, Enter starts a new line, the box stops at maxLength, and the card sends the text with \n for each line break.

Additional Resources​