欢迎消息Bot Framework v4 Node.js

时间:2018-12-10 11:01:54

标签: node.js azure botframework

我正在开发基于Microsoft Bot Framework(https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0)的多渠道机器人(专注于网络和电报)

我对用户收到的初始消息感到困惑。 我的机器人是基于Microsoft发布的复杂机器人:https://github.com/Microsoft/BotFramework-Samples/tree/master/SDKV4-Samples/js/complexDialogBot

问题,我看到的是在模拟器bot中运行良好,在Web用户上没有收到欢迎消息。我已经使用iframe集成了该机器人。

我正在检查活动类型以及将成员添加到聊天中的时间,但是好像不是在网络上触发的。

if (turnContext.activity.type === ActivityTypes.ConversationUpdate) {
    if (turnContext.activity.membersAdded && turnContext.activity.membersAdded.length > 0) {
        await this.sendWelcomeMessage(turnContext);
    }
}

我看到了类似的问题,但无论是针对bot框架v3还是C#实现(例如Welcome message not visibile in Webchat,but work in EmulatorWelcome Message not working in Azure portal using Microsoft Bot Builder SDK(v4) for nodejs

2 个答案:

答案 0 :(得分:1)

尝试使用此

enter code here
         this.onMembersAdded(async context => {
        const membersAdded = context.activity.membersAdded;
        for (let cnt = 0; cnt < membersAdded.length; cnt++) {
            if (membersAdded[cnt].id == context.activity.recipient.id) {                    
                 const welcomeCard = CardFactory.adaptiveCard(WelcomeCard);
          }
        }
    });

答案 1 :(得分:0)

您可以在以下代码中解决您的问题 在iframe中集成机器人,您可以编写成员在!turnContext.responded

内部添加代码副本
if (turnContext.activity.type === ActivityTypes.Message) {
     if (!turnContext.responded) {
            await this.sendWelcomeMessage(turnContext);
     }
}

相关问题