0
votes

I am working with Bot framework v4 webchat, trying to send a welcome message when a bot is initialized. First i send an event activity to the bot from webchat channel and got a 200 status response from but i can't able to capture the event activity in OneventActivityAsync action.

I have go though the below given solution.

https://github.com/microsoft/BotFramework-WebChat/tree/master/samples/04.api/a.welcome-event

OneventActivityAsync Section:

    if (turnContext.Activity.Name == "webchat/join")
     {
         await turnContext.SendActivityAsync("Welcome Message!");
     }

Could anyone help me on this?

I really appreciate any help :)

1

1 Answers

0
votes

Your approach should work for v3. But for v4 you need to handle this event in OnMembersAddedAsync method.

protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITur

nContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
    {
        if (turnContext.Activity.ChannelId != "webchat" && turnContext.Activity.ChannelId != "directline") {
    
            foreach (var member in membersAdded)
            {
                if (member.Id != turnContext.Activity.Recipient.Id)
                {
                    await turnContext.SendActivityAsync("Welcome");
                }
            }
        }
    }

Br, Pdeepa