You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法在Adaptive Card中动态显示Power Virtual Agent数据

问题求助:Power Virtual Agent中Adaptive Card无法正确渲染工单数组数据

我正在开发Power Virtual Agent,通过Power Automate从工单系统拉取数据,打算用Adaptive Card展示给用户,但没法把工单数据正确关联到对应变量。在Adaptive Card设计器里调试很久都没解决,以下是相关信息,恳请协助:

一、Power Automate流示例输出JSON

{
  "capitalName": "John",
  "returnString": "Success",
  "returnCode": true,
  "returnTickets": [
    {
      "id": 114762,
      "summary": "Example Ticket 1",
      "company": "Apple",
      "resources": "Michael, John"
    },
    {
      "id": 117572,
      "summary": "Example Ticket 2",
      "company": "Amazon",
      "resources": "John"
    },
    {
      "id": 121946,
      "summary": "Example Ticket 3",
      "company": "Microsoft",
      "resources": "Peter, Charles, Steven, John"
    },
    {
      "id": 122116,
      "summary": "Example Ticket 4",
      "company": "Facebook",
      "resources": "Steven, John"
    },
    {
      "id": 99336,
      "summary": "Example Ticket 5",
      "company": "Tesla",
      "resources": "Michael, John"
    },
    {
      "id": 119254,
      "summary": "Example Ticket 6",
      "company": "Gamestop",
      "resources": "Michael, John"
    }
  ]
}

二、当前使用的Adaptive Card JSON

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.4",
  "body": [
    {
      "type": "TextBlock",
      "text": "Tickets",
      "weight": "Bolder",
      "size": "Medium"
    },
    {
      "type": "TextBlock",
      "text": "{{$root.returnTickets.length}} tickets found"
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "title": "Ticket ID",
          "value": "{{id}}"
        },
        {
          "title": "Summary",
          "value": "{{summary}}"
        },
        {
          "title": "Company",
          "value": "{{company}}"
        },
        {
          "title": "Resources",
          "value": "{{resources}}"
        }
      ],
      "separator": true,
      "spacing": "Medium",
      "factsProperty": "returnTickets"
    }
  ]
}

三、测试异常效果

测试时卡片仅显示了标题和工单数量,所有工单详情的FactSet值均为空,没有正确渲染出每一条工单的ID、摘要、公司和资源信息。


解决方案

问题原因

错误使用了FactSet的factsProperty属性,Adaptive Card中遍历数组渲染重复内容,需要通过容器(Container)的items属性绑定数组,再在每个子项中定义要重复的布局。

修正后的Adaptive Card JSON

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.4",
  "body": [
    {
      "type": "TextBlock",
      "text": "工单列表",
      "weight": "Bolder",
      "size": "Medium"
    },
    {
      "type": "TextBlock",
      "text": "{{$root.returnTickets.length}} 条工单",
      "spacing": "Small"
    },
    {
      "type": "Container",
      "items": [
        {
          "type": "FactSet",
          "facts": [
            {
              "title": "工单ID",
              "value": "{{id}}"
            },
            {
              "title": "摘要",
              "value": "{{summary}}"
            },
            {
              "title": "公司",
              "value": "{{company}}"
            },
            {
              "title": "关联资源",
              "value": "{{resources}}"
            }
          ],
          "separator": true,
          "spacing": "Medium"
        }
      ],
      "$data": "{{$root.returnTickets}}"
    }
  ]
}

关键说明

  • 使用Container并通过$data绑定$root.returnTickets数组,实现对工单列表的遍历
  • 容器内的items定义了每个工单要渲染的FactSet结构,每个子项会自动继承数组中对应对象的上下文,因此可以直接使用{{id}}、{{summary}}等字段
  • 保留了原有的工单数量统计,同时将标题改为中文更贴合使用场景(可根据需求改回英文)

内容的提问来源于stack exchange,提问作者Active Citizen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 09:45:06