【发布时间】:2019-05-09 09:58:08
【问题描述】:
根据这个官方示例项目 (https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/typescript_nodejs/13.core-bot/src/bots/dialogAndWelcomeBot.ts),我可以识别新成员并向他们发送欢迎消息(我的代码):
this.onMembersAdded(async (context) => {
const welcomeCardTemplate = require("../lib/data/resources/cards/welcomeCard.json");
const membersAdded = context.activity.membersAdded;
for (const member of membersAdded) {
if (member.id !== context.activity.recipient.id) {
const welcomeCard = CardFactory.adaptiveCard(welcomeCardTemplate );
await context.sendActivity({ attachments: [welcomeCard] });
}
}
});
使用模拟器时效果很好。一旦我连接到聊天,我就会收到我的欢迎消息,但是当使用 Azure 上的聊天或 WebChat 时,直到我第一次在聊天中输入某种文本输入时才会触发它。
我注意到的一件事是,当我使用模拟器时,一旦我连接到聊天,两个活动就会发送到机器人,一个包含机器人的 ID,另一个包含用户的 ID,但是当使用其他聊天选项(Azure Chat 和 WebChat)时,只会发送一个活动(其中 memberId 与 recipientId 相同),因此它永远不会超过 if 语句。
我在这里遗漏了什么,为什么 Azure Chat 和 WebChat 只发送一个活动?
【问题讨论】:
标签: node.js botframework chatbot