如何使用 PowerAutomate 更新 Teamscard

问题描述 投票:0回答:1

我需要帮助,这是一张动态团队卡。它可以包含多个测试用例:

{
  "type": "AdaptiveCard",
  "body": [
    {
      "size": "medium",
      "text": "TestGroup: 11 test case(s) - 4 failures - 63.64% success rate - 178.38099999999997sec total time",
      "weight": "bolder",
      "type": "TextBlock"
    },
    {
      "title": "Test1 failed after 10.402sec. Owner: xyz",
      "valueOff": "False",
      "valueOn": "True",
      "value": "false",
      "id": "Test1",
      "type": "Input.Toggle"
    },
    {
      "size": "small",
      "text": "Pipeline Url: xyz.de",
      "weight": "bolder",
      "type": "TextBlock"
    }
  ],
  "actions": [
    {
      "title": "Save",
      "type": "Action.Submit"
    }
  ],
  "version": "1.0",
  "msTeams": {
    "width": "full"
  }
}

现在我想使用 PowerAutomate 创建一个在“当有人响应自适应卡时”时触发的流程。这一切都运作得非常好。您会收到以下回复:

{
  "entity": {
    "teamsFlowRunContext": {
      "MessagePayload": {
        "Id": "1693912153540",
        "From": {
          "Application": null,
          "Conversation": null,
          "Device": null,
          "User": {
            "DisplayName": "test",
            "Id": "id"
          }
        },
        "Body": {
          "ContentType": null,
          "Content": null
        },
        "Subject": null,
        "LinkToMessage": "link",
        "ChannelData": null
      },
      "Id": null,
      "ChannelData": {
        "EventType": null,
        "InvalidateInvokeCache": null,
        "Team": null,
        "Tenant": {
          "Id": "tenantid"
        },
        "Channel": null,
        "Notification": null,
        "OnBehalfOf": null
      },
      "From": {
        "Id": "xyz",
        "Name": "Flow",
        "Role": null,
        "AadObjectId": null,
        "Properties": null
      },
      "Conversation": {
        "Id": "xyz",
        "Name": "NotificationTest",
        "IsGroup": true
      },
      "Locale": "de-DE",
      "CommandContext": null,
      "LocalTimezone": null
    },
    "cardOutputs": {
      "Test1": "false",
      "Test2": "True",
      "Test3": "false"
    }
  }
}

然后我使用 Select 将 cardOutputs 转换为数组,以便我可以循环它们。但现在我只是不明白如何以更新toggle.inputs 的值的方式编辑旧消息中的JSON

我知道如何寄走新的自适应卡,但不知道如何更改或重建它...... 最重要的是,我有一个循环遍历主体,然后循环遍历卡输出,然后是一个将 ID 与密钥进行比较的条件。如果合适,则应该替换toggle.input的值。

是否有更好的解决方案,例如以某种方式简单地将旧消息以编辑版本发送,然后简单地将其发送回团队?

json automation microsoft-teams power-automate adaptive-cards
1个回答
0
投票

要使用 Power Automate 更新 Teams 卡,您可以使用 Power Automate 中的“更新自适应卡”操作。此操作允许您修改现有自适应卡的内容并将其发送回 Teams。

以下是使用 Power Automate 更新 Teams 卡的步骤:

  • 在 Power Automate 中创建新流程并选择触发器 适合您的场景。例如,您可以使用“当新的 消息已发布在频道中”触发器。

  • 添加操作以获取 Teams 消息的详细信息。例如, 您可以使用“获取消息详细信息”操作并提供 必要的输入,例如团队 ID、频道 ID 和消息 ID。

  • 添加更新自适应卡的操作。搜索“更新 自适应卡”操作并选择它。

  • 通过提供以下信息来配置“更新自适应卡”操作 必要的输入:

    Card ID: This is the ID of the Adaptive Card you want to update. You
    can find the Card ID in the message details obtained in the previous
    step.
    
    Card JSON: This is the updated JSON representation of the Adaptive
    Card. You can modify the card content using expressions or dynamic
    content from previous steps in the flow.
    
  • 保存流程并通过在指定的位置发布新消息来测试它 团队频道。消息中的自适应卡将更新为 您在“更新自适应卡”操作中所做的更改。

注意:“更新自适应卡”操作需要将“Microsoft Teams - 可操作消息”连接器添加到您的 Power Automate 环境中。确保您拥有添加连接器和使用此操作所需的权限。

您可以在 Microsoft Teams 文档中找到有关使用 Power Automate 更新 Teams 卡的更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.