我正在尝试使用带有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/