首页 > 解决方案 > 使用任务模块显示 Web 框架有困难 - Microsoft Bot Framework

问题描述

我遵循了微软文档

从中,我了解到“我可以运行我自己的自定义 HTML/JavaScript 代码”并使用任务模块将其显示在团队中。

我已完成所有建议我的卡每次调用任务模块时显示为空白的事情。

图 1图 2

我正在使用 BotBuilder-Sample Node JS SDK

teamTaskModuleBot.js 文件包含

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

const {
    TeamsActivityHandler,
    MessageFactory,
    CardFactory,
} = require("botbuilder");


class TeamsTaskModuleBot extends TeamsActivityHandler
{
    constructor ()
    {
        super();
        // See https://aka.ms/about-bot-activity-message to learn more about the message and other activity types.
        this.onMessage(async (context,next) =>
        {
            const card = this.getHeroCardMenu();
            const message = MessageFactory.attachment(card);
            await context.sendActivity(message);

            // By calling next() you ensure that the next BotHandler is run.
            await next();
        });

        this.onMembersAdded(async (context,next) =>
        {
            const card = this.getHeroCardMenu();
            const message = MessageFactory.attachment(card);
            await context.sendActivity(message);
            // By calling next() you ensure that the next BotHandler is run.
            await next();
        });
    }

    getHeroCardMenu ()
    {
        return CardFactory.heroCard(
            "Task Module Invocation from Hero Card",
            null, // No images
            [
                {
                    type: "invoke",
                    title: "Open",
                    value: {type: "task/fetch"},
                },
            ]
        );
    }

    handleTeamsTaskModuleFetch (context,taskModuleRequest)
    {
        // taskModuleRequest.data can be checked to determine different paths.
        return {
            task: {
                type: "continue",
                value: {
                    url: "https://botiframe.netlify.app/index.html",
                    height: "medium",
                    width: "medium",
                    title: "Task Module Bot",
                    fallbackUrl: "https://botiframe.netlify.app/index.html"
                },
            },
        };
    }

}

module.exports.TeamsTaskModuleBot = TeamsTaskModuleBot;

我的 manifest.json 文件

{
  "$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
  "manifestVersion": "1.5",
  "version": "1.0.0",
  "id": "208a91ef-baa9-460d-bf8d-7c7bc2f475e0",
  "packageName": "com.dipolediamond.taskmodule",
  "developer": {
    "name": "dipoleDiamond Ltd",
    "websiteUrl": "https://www.dipolediamond.com",
    "privacyUrl": "https://www.dipolediamond.com/blog",
    "termsOfUseUrl": "https://www.dipolediamond.com/contact"
  },
  "icons": {
    "color": "icon-color.png",
    "outline": "icon-outline.png"
  },
  "name": {
    "short": "Task Module Bot",
    "full": "Simple Task Module Bot"
  },
  "description": {
    "short": "Test Task Module Sample Bot",
    "full": "Simple Task Module Sample Bot"
  },
  "accentColor": "#FFFFFF",
  "bots": [
    {
      "botId": "208a91ef-baa9-460d-xxxx-xxxxxxx",
      "scopes": ["personal", "team", "groupchat"],
      "supportsFiles": false,
      "isNotificationOnly": false
    }
  ],
  "permissions": ["identity", "messageTeamMembers"],

  "composeExtensions": [
    {
      "botId": "208a91ef-baa9-460d-xxxx-xxxx",
      "canUpdateConfiguration": true,
      "commands": [],
      "messageHandlers": [
        {
          "type": "link",
          "value": {
            "domains":"www.botiframe.netlify.app"
            ]
          }
        }
      ]
    }
  ],
  "validDomains": ["www.botiframe.netlify.app"]
}

标签: botframeworkmicrosoft-teams

解决方案


在显示您的 Web 内容之前,Teams 会对结束地址进行一些基本验证。正如您所做的那样,这需要使用validDomainsdomains部分注册域。但是,当我访问该站点时,我收到了一个证书错误,因此 Teams 很可能因此而阻止了你的站点。您是否能够解决该问题(自定义域或证书匹配域(证书适用于 *.netlify.com,但您的网站在 netlify.app 上运行)?首先尝试一下。


推荐阅读