template_card
Convert static Adaptive Cards into templates with data binding expressions to create dynamic, reusable card components for Microsoft Teams, Outlook, and Copilot.
Instructions
Convert a static Adaptive Card into an Adaptive Card Template with ${expression} data binding.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| card | No | A static Adaptive Card or cardId to convert into a template | |
| dataShape | No | Optional data shape hint | |
| description | No | If no card is provided, describe the card to generate as a template |
Implementation Reference
- The handleTemplateCard function is the primary handler for the 'template_card' tool. It takes a static Adaptive Card or a description, converts it into an Adaptive Card Template, generates sample data, and creates a binding guide.
export function handleTemplateCard(input: TemplateCardInput): TemplateCardOutput { const { card, dataShape, description } = input; let sourceCard: Record<string, unknown>; if (card) { sourceCard = JSON.parse(JSON.stringify(card)); } else if (description) { // Generate a card from the description, then templatize it sourceCard = assembleCard({ content: description, version: "1.6", }); } else { throw new Error("Either 'card' or 'description' must be provided"); } const expressions: ExpressionEntry[] = []; const sampleData: Record<string, unknown> = {}; const repeatedDataSamples: Record<string, unknown[]> = {}; // Templatize the card const template = templatizeNode(sourceCard, "$", expressions, sampleData, repeatedDataSamples, dataShape); // Merge repeated data samples into sampleData for (const [key, samples] of Object.entries(repeatedDataSamples)) { sampleData[key] = samples; } // Build binding guide const bindingGuide = buildBindingGuide(expressions, sampleData); return { template: template as Record<string, unknown>, sampleData, expressions, bindingGuide, }; }