Skip to content

Function: documentCardSpec()

documentCardSpec(value): { actions?: object[]; facts?: object[]; subtitle?: string; text?: string; title: string; } | null

Recover a card.CardSpec from a full Adaptive Card DOCUMENT.

A capable model asked for “a Microsoft Teams Adaptive Card” often answers with the finished 1.5 document instead of the small spec - correct Adaptive Card JSON, wrong schema, so structuredOutput rejects it (title: expected string) and a genuinely good answer is thrown away. Reading the document back into the spec vocabulary keeps it: the heading TextBlocks become title/subtitle, remaining TextBlocks the body, the FactSet the facts, and any Action.OpenUrl the actions.

Deliberately tolerant about the container: type may be missing and the body may nest elements inside a Container / ColumnSet, so blocks are collected recursively and anything unrecognized is ignored.

unknown

{ actions?: object[]; facts?: object[]; subtitle?: string; text?: string; title: string; } | null