Jasmin_smsidea Ответов: 1

Приветственное сообщение не отображается в azure bot


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.


Что я уже пробовал:

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

1 Ответов