Microsoft Teams

Convert generative UI trees to Teams Adaptive Cards and decode Action.Submit payloads back into $action payloads.

API Reference

AdaptiveCardResult

The card and non-fatal warnings produced by toAdaptiveCard.

AdaptiveCardResult
cardTeamsAdaptiveCard

TeamsAdaptiveCard
$schema"http://adaptivecards.io/schemas/adaptive-card.json"

type"AdaptiveCard"

version"1.5"

bodyreadonly TeamsCardElement[]

actionsreadonly TeamsCardAction[]

warningsTeamsConversionWarning[]

decodeSubmitData

Decodes the merged activity.value object a Teams bot receives on Action.Submit, inverting the aui envelope buildSubmitAction nests the resume action under. Adaptive Cards fold every other same-card input's value into the same submit object keyed by its id, so every top-level key besides aui is collected into $input (omitted when there are none). aui is reserved for the envelope: toAdaptiveCard renames any input whose id would collide to an unused id derived from it before encoding, so a same-card input value can never land on this key. $input and type are reserved on the way out: a $input key inside the envelope payload is dropped so the slot only ever reflects same-card input values, and the envelope's own type wins over a payload key of the same name. Every collected key (in payload or $input) is kept as an own data property of the returned object, even a __proto__ or constructor key, since the object is always built by spreading and Object.fromEntries rather than by keyed assignment. Envelope keys are read as own properties only, so prototype-inherited aui, type, or payload values never dispatch. Returns undefined for a missing or malformed aui envelope; never throws.

decodeSubmitData
valueunknown

TeamsAttachmentsResult

The attachments and non-fatal warnings produced by toTeamsAttachments.

TeamsAttachmentsResult
attachmentsTeamsCardAttachment[]

attachmentLayout?"carousel"

warningsTeamsConversionWarning[]

TeamsConversionWarning

A non-fatal note reported during Teams conversion.

clamped removed content to fit a limit, dropped discarded a node or one of its props and may leave a placeholder note behind, and fallback emitted the node in a different form than requested. advisory changed nothing at all and notes content Teams may still render poorly or refuse, such as a payload over the byte budget or a Row past the recommended column count.

TeamsConversionWarning
code"clamped" | "dropped" | "fallback" | "advisory"

componentstring

detailstring

toAdaptiveCard

Converts a generative-ui tree into a Microsoft Teams Adaptive Card and non-fatal conversion warnings. Sizes, weights, and colors map to Adaptive Card's semantic enums rather than raw values. An Input/Select/RadioGroup/ Checkbox/DatePicker whose id would be the reserved RESERVED_INPUT_ID is renamed with a warning (see decodeSubmitData). Never throws: an unknown $type is skipped with a "dropped" warning, and a malformed input resolves to an empty card plus a "dropped" warning instead of throwing.

toAdaptiveCard
nodeunknown

_options?ToAdaptiveCardOptions

ToAdaptiveCardOptions

Options accepted by toAdaptiveCard and toTeamsAttachments. Reserved for future extension; no options are currently defined.

export interface ToAdaptiveCardOptions {}

toTeamsAttachments

Converts a generative-ui tree into Teams bot-framework message attachments. A root-level Carousel becomes one attachment per Card child (clamped to CAROUSEL_ATTACHMENT_CAP) with attachmentLayout: "carousel"; anything else converts through toAdaptiveCard's engine into a single attachment. Never throws.

toTeamsAttachments
nodeunknown

_options?ToAdaptiveCardOptions