尽管服务器已命中并且已配置机器人,但 Microsoft Bot 未响应

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

我正在使用nodeJs开发一个Teams Command应用程序,但是,当我在团队中预览该应用程序并触发helloWorld命令时,服务器被击中,但它没有响应。 我知道它被击中了,因为我在那里添加了一个日志,但不知怎的,它并没有比这更进一步。

这是我的index.ts代码:

import express from 'express';
import { commandApp } from "./internal/initialize";
import { TeamsBot } from "./teamsBot";
const index = express();
const port = process.env.PORT || 3100;

const teamsBot = new TeamsBot();
index.post("/api/messages", async (req, res) => {
    console.log('Endpoint was hit!') --> Nothing after this line works
    await commandApp.requestHandler(req, res, async (context) => {
        console.log("context: ", context);
        await teamsBot.run(context);
    });
});

// Start the server
index.listen(port, () => {
    console.log(`Server is running on port ${port}`);
});

我在 azure 中创建了机器人,并在那里进行了应用程序注册,以获取机器人的秘密。我已将这些信息添加到服务器的 .env 文件中,如下所示:

BOT_ID=f5686cc4-c90c-49f4-89ea-d5fb5f92fa35 BOT_PASSWORD=xxxxxxxxxxxx

我还使用 NGROK 创建从本地主机服务器到机器人的隧道。我已将其添加到 azure 的机器人端点中。

因此,每当我在 Teams 中预览 Bot 并点击 helloWorld 命令时,我都会在控制台中看到以下内容: Console log result

我错过了什么?

编辑:对于服务器,我使用了teamFX CLI生成的服务器,并将其转换为使用express而不是restify。

编辑2:Bot provisioned in Azure

编辑 3:附加调试器并在 server.post("/api/messages") 函数末尾添加断点后,我发现收到 401 错误:

401 error

我错过了什么?我刚刚创建了一个新秘密并将其粘贴到 .env 中的 BOT_PASSWORD 属性中。

botframework microsoft-teams teams-toolkit microsoft-teams-js
1个回答
0
投票

经过长时间的搜索,我发现 azure 和 teamFx CLI 无法处理 Azure 应用程序注册内发生的更改。我通过从头开始创建一个新的 Azure 应用程序注册,然后创建一个与该注册关联的新 Azure 机器人,然后使用 BOT_ID 和新生成的 BOT_PASSWORD 并在我的服务器中使用这些内容来解决 401 问题。

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