3
votes

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)

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

Issue I'm seeing is that in the emulator bot is working great, on the web user is not greeted with the welcome message. I've used iframe to integrate the bot.

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)

2
On the web, which version of Webchat are you using? This reply is still valid for v3 of webchat stackoverflow.com/questions/50363035/…Nicolas R
When you say you're not seeing it in webchat, do you mean you've pulled the <iframe> from the channels blade, put it in a html page and you're viewing that? or are you using "Test in WebChat" blade on Azure? Cuz the 'Test in Webchat' doesn't always send welcome messages as expected, due to how welcome messages are implemented vs how 'Test' is implemented.JJ_Wailes

2 Answers

2
votes

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

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

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