简体   繁体   English

欢迎消息 Bot Framework v4 nodejs

[英]Welcome message Bot Framework v4 nodejs

I'm developing a multichannel bot (focusing on web and telegram) that's based on Microsoft's Bot Framework ( https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0 )我正在开发一个基于 Microsoft Bot Framework ( https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service- 4.0 )

I'm stuck with the initial message the user is getting.我被用户收到的初始消息困住了。 My bot is based on the complex bot published by Microsoft: https://github.com/Microsoft/BotFramework-Samples/tree/master/SDKV4-Samples/js/complexDialogBot我的机器人基于微软发布的复杂机器人: https : //github.com/Microsoft/BotFramework-Samples/tree/master/SDKV4-Samples/js/complexDialogBot

Issue I'm seeing is that in the emulator bot is working great, on the web user is not greeted with the welcome message.我看到的问题是,模拟器机器人运行良好,但 Web 用户没有收到欢迎消息。 I've used iframe to integrate the bot.我已经使用 iframe 来集成机器人。

I'm checking activity types and when members are added to the chat, but seems like it's not triggering on the web.我正在检查活动类型以及何时将成员添加到聊天中,但似乎没有在网络上触发。

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

I saw similar questions asked but either for bot framework v3 or C# implementation (like this one Welcome message not visibile in Webchat,but work in Emulator and Welcome Message not working in Azure portal using Microsoft Bot Builder SDK(v4) for nodejs )我看到了类似的问题,但无论是机器人框架 v3 还是 C# 实现(比如这个欢迎消息在网络聊天中不可见,但在模拟器中工作欢迎消息在使用 Microsoft Bot Builder SDK(v4) for nodejs 的 Azure 门户中不起作用

try using this尝试使用这个

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);
          }
        }
    });

You can solve your problem in below code in iframe to integrate the bot you can write member Adding code copy in inside !turnContext.responded您可以在 iframe 中的以下代码中解决您的问题以集成您可以编写成员的 bot 在里面添加代码副本!turnContext.responded

if (turnContext.activity.type === ActivityTypes.Message) {
     if (!turnContext.responded) {
            await this.sendWelcomeMessage(turnContext);
     }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM