【问题标题】:Is the Bot Framework Emulator handling new members differently from Bot Framework Webchat?Bot Framework Emulator 处理新成员的方式是否与 Bot Framework Webchat 不同?
【发布时间】: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


    【解决方案1】:

    此时,WebChat 和 DirectLine 在某些场景(如您描述的场景)中的行为与模拟器不同。对于这种特殊情况,有一个open issue,您可以在其中找到更多信息。

    如问题中所述,there is a workaround 强制执行 ConversationUpdate 事件,您可以尝试测试它是否适合您的需求(我自己没有尝试过)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-04
      • 1970-01-01
      • 2023-03-31
      相关资源
      最近更新 更多