Skip to main content
Glama

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
NameRequiredDescriptionDefault
cardNoA static Adaptive Card or cardId to convert into a template
dataShapeNoOptional data shape hint
descriptionNoIf 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,
      };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/VikrantSingh01/adaptive-cards-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server