Skip to main content
Glama

data_to_card

Convert structured data like JSON or CSV into optimized Adaptive Cards for Microsoft Teams, Outlook, and other platforms. Automatically selects or specifies presentation formats including tables, charts, lists, and facts.

Instructions

Convert structured data (JSON array, CSV, key-value object) into the optimal Adaptive Card presentation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesThe data to convert — JSON object, JSON array of objects, or CSV string
presentationNoPresentation type. "auto" (default) auto-selects
titleNoTitle for the card header
hostNoTarget host app. Default: generic
templateModeNoGenerate a templated card with ${expression} data binding. Default: false

Implementation Reference

  • The handler function `handleDataToCard` is the main logic responsible for converting structured data into an Adaptive Card, utilizing LLMs for complex data or deterministic assembly for simpler cases.
    export async function handleDataToCard(
      input: DataToCardInput,
    ): Promise<GenerateCardOutput> {
      const {
        data,
        presentation = "auto",
        title,
        host = "generic",
        theme,
        templateMode = false,
      } = input;
    
      const analysis = analyzeData(data);
      let card: Record<string, unknown>;
      let designNotes: string;
    
      // Try LLM for complex data structures
      if (isLLMAvailable() && (analysis.shape === "nested-object" || analysis.shape === "unknown")) {
        try {
          const systemPrompt = buildSystemPrompt(host);
          const userPrompt = buildDataToCardPrompt({
            data,
            title,
            presentation,
          });
    
          const response = await generateWithLLM({
            systemPrompt,
            userPrompt,
            maxTokens: 4096,
          });
    
          const parsed = extractJSON(response.content);
          if (parsed) {
            card = parsed;
            designNotes = `AI-generated from ${analysis.shape} data. ${analysis.summary}. Presentation: ${presentation === "auto" ? analysis.presentation : presentation}.`;
          } else {
            throw new Error("Failed to parse LLM output");
          }
        } catch {
          // Fallback to deterministic
          card = assembleCard({
            data,
            title,
            presentation,
            host,
          });
          designNotes = `Deterministic generation from ${analysis.shape} data. ${analysis.summary}. Auto-selected: ${analysis.presentation}.`;
        }
      } else {
        // Deterministic generation
        card = assembleCard({
          data,
          title,
          presentation,
          host,
        });
        designNotes = `Generated from ${analysis.shape} data. ${analysis.summary}. Presentation: ${presentation === "auto" ? analysis.presentation : presentation}.`;
      }
    
      // Validate
      const validation = handleValidateCard({ card, host });
    
      return {
        card,
        validation,
        designNotes,
      };
    }

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