[英]Error:This method is only valid within the scope of ms teams team
I get an error as mentioned in the title when i use Teamsinfo's getTeamChannels and getTeamsDetail methods where as when i use TeamsInfo.getMembers.当我使用 Teamsinfo 的 getTeamChannels 和 getTeamsDetail 方法时,我收到标题中提到的错误,而当我使用 TeamsInfo.getMembers 时。 The code works fine perfectly.
代码完美运行。
im using msteams to send messages hence the scope issue shouldnt really come up.我使用 msteams 发送消息,因此范围问题不应该真正出现。 Also getMembers works totally fine.
getMembers 也完全正常。 not sure why the other two doesn't
不知道为什么另外两个没有
Code without issue-没有问题的代码-
export class MyBot 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 (turnContext, next) => {
const members = await TeamsInfo.getMembers(turnContext);
// By calling next() you ensure that the next BotHandler is run.
await next();
});
}
}
Code with issue-有问题的代码-
export class MyBot 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 (turnContext, next) => {
const teamDetails = await TeamsInfo.getTeamDetails(turnContext);
// By calling next() you ensure that the next BotHandler is run.
await next();
});
}
}
Any known issue?任何已知问题? Versions:"botbuilder-azure": "^4.7.2", "botbuilder": "^4.7.2"
版本:“botbuilder-azure”:“^4.7.2”,“botbuilder”:“^4.7.2”
Based on the comments above, I think I've got an answer:根据上面的评论,我想我有一个答案:
"getMembers" is working because, in a 1-1 chat (just you and the bot), there are "members" of the conversation. “getMembers”之所以有效,是因为在一对一聊天中(只有您和机器人),对话中有“成员”。 However, there are 3 different kinds of chats a bot can participate in:
但是,机器人可以参与 3 种不同类型的聊天:
1) a "1-1", like you're having now 2) a "group chat", where there's a direct chat between, for example, you, one or more other users, and the bot (this will also appear in the "chat" section on the left menu in Teams) 3) A "channel" inside a "Team" in Teams. 1) 一个“1-1”,就像你现在有的 2) 一个“群聊”,例如,你、一个或多个其他用户和机器人之间的直接聊天(这也会出现在团队左侧菜单上的“聊天”部分)3)团队中“团队”内的“频道”。 For instance, you might have a team like "Finance" with a "channel" like "Accounts receivable", and your bot can be connected to this team+channel
例如,你可能有一个像“财务”这样的团队,有一个像“应收账款”这样的“频道”,你的机器人可以连接到这个团队+频道
The methods you're calling depend on where the bot conversation is taking place.您调用的方法取决于机器人对话发生的位置。 For instance, "getTeamDetails" will only work in scenario (3) above, where the bot is actually in a team.
例如,“getTeamDetails”仅适用于上述场景 (3),其中机器人实际上在一个团队中。
Hope that helps explain?希望这有助于解释?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.