Click here to Skip to main content
15,886,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created one chatbot in Asp.net core using c#, I am facing issue regarding welcome message when the user opens chatbot the first time. it is working fine when I use Microsoft bot framework emulator. but when I create bot service in azure bot option then it is not through a welcome message. but yes, when you type anything and press send button after that it is displayed a welcome message. Means, azure bot receive any message then it responds but I want to display my welcome message first when the user open chat bot panel. any idea what is the solution in it?

i used this code, it is working fine in local bot framework emulator, but not in azure bot.


What I have tried:

C#
namespace Microsoft.BotBuilderSamples
{
    public class DialogAndWelcomeBot<T> : DialogBot<T> where T : Dialog
    {
        public DialogAndWelcomeBot(ConversationState conversationState, UserState userState, T dialog, ILogger<DialogBot<T>> logger)
            : base(conversationState, userState, dialog, logger)
        {
        }

        protected override async Task OnMembersAddedAsync(
            IList<ChannelAccount> membersAdded,
            ITurnContext<IConversationUpdateActivity> turnContext,
            CancellationToken cancellationToken)
        {
            foreach (var member in membersAdded)
            {   
                if (member.Id != turnContext.Activity.Recipient.Id)
                {   
                    var replyOne = MessageFactory.Text($"Hi there! I'm bot. ");
                    await turnContext.SendActivityAsync(replyOne, cancellationToken);
                    var replyTwo = MessageFactory.Text($"How may i assist you?");
                    await turnContext.SendActivityAsync(replyTwo, cancellationToken);
                }
            }
        }
    }
}
Posted
Updated 25-Jan-20 4:30am

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900