node.js - 错误接收器-[onTurnError] : TypeError: Cannot read property 'getTeamDetails' of undefined

标签 node.js botframework microsoft-teams

我正在尝试使用带有nodejs的微软机器人框架构建一个机器人

当我使用下面的代码时,我收到错误 - [onTurnError]:TypeError:无法读取未定义的属性“getTeamDetails”

const { ActivityHandler,TeamsInfo} = require('botbuilder');

export class MyBot extends ActivityHandler {
    constructor() {
        super();

        // See https://aka.ms/about-bot-activity-message to learn more about the message and other activity types.
        this.onMessage(async (turnContext, next) => {
            const teamDetails = await TeamsInfo.getTeamDetails(turnContext);
            if (teamDetails) {
                await turnContext.sendActivity(`The group ID is: ${teamDetails.aadGroupId}`);
            } else {
                await turnContext.sendActivity('This message did not come from a channel in a team.');
            }

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

最佳答案

看来您仍在使用 botbuilder 4.5.3,但是 support for Teams has been added in 4.6.0 。当您将软件包更新到(至少)4.6 时,它将起作用。

npm update

我发现您仍在使用 botbuilder-teams,它已被弃用,并显示以下弃用通知。

The functionality of this SDK has been incorporated into the core Bot Framework SDK as of v4.6. Upgrade your Bot Framework SDK to access Teams-specific functions.

如果您不再使用该软件包中的任何功能,则可以卸载 botbuilder-teams

npm uninstall botbuilder-teams

关于node.js - 错误接收器-[onTurnError] : TypeError: Cannot read property 'getTeamDetails' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60167074/

相关文章:

node.js - 将文件存储在本地哪里,以便在删除 Electron 应用程序后不会删除它们?

azure - 未找到 AZ 扩展机器人服务

javascript - 如何更改 Bot/Skype channel 传入消息文本格式

node.js - Microsoft Teams botbuilder 如何在另一个 channel 中创建对话

node.js - 如何在本地计算机上模拟 AWS Parameter Store 进行 lambda 函数开发?

node.js - 将 socket.io 切换到端口 80 导致传输切换到 xhr 轮询

java - MSGraph API 取消存档团队和恢复组不起作用

bots - 使用自定义机器人将微软团队与自定义应用程序集成

javascript - 请求 - 返回一个元素

c# - 将图像上传到 Skype BOT