在 Microsoft Teams 中点击 Hero Card 按钮查看网页

View webpage on button click on Hero Card in Microsoft Teams

我在 MS Teams 中有一个消息扩展 运行ning。

搜索列表显示Hero Card

选择其中之一后,它会在聊天中显示如下内容。

显示按钮的部分代码:

...

heroCard.content.buttons = [{
   type: 'invoke',
   title: 'Open Attachment',
   value: {
    type: "task/fetch",
    messageId: "12345",
   }
}];

我正在寻找 运行 我的 angular 应用程序,点击 Open Attachment 显示文档。

我找到了继续使用 Microsoft Docs: Use task modules from bots

的方法

首先我需要调整英雄卡按钮来传递我的数据。

...

heroCard.content.buttons = [{
   type: 'invoke',
   title: 'Open Attachment',
   value: {
     type: "task/fetch",
     messageId: "12345",
     data: attachments
   }
}];

第二件事是处理fetch请求:

async handleTeamsTaskModuleFetch(context, action) {

   var attachments = action.data.data

   return {
     task: {
       type: 'continue',
       value: {
         height: 400,
         width: 400,
         title: 'View Documents',
         url: `https://example.io?data=${attachments}`
       }
     }
  };
}

注意:URL 必须在清单的有效域中 - 否则您将看到空白页。


下面是最终输出: