none
web chat at start show me diferent inital message RRS feed

  • Question

  • When i use the Qnabot with web chat at start show me (Hello and welcome!) i have in my code another initial mesage like this => Hola, bienvenido al ChatBot de binapps ¿En que te puedo ayudar?
    Thursday, November 14, 2019 3:49 PM

All replies

  • Hi Daniel,

    Thanks for reaching out to us, may I know how you set your initial message? Could you please share the tutorial you are referring to so that we can address your problem quick. Thanks!

    Regards,

    Yutong

    Thursday, November 14, 2019 11:50 PM
    Moderator
  • I have a piece of code

    // Copyright (c) Microsoft Corporation. All rights reserved.
    // Licensed under the MIT License.
    
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Microsoft.Bot.Builder;
    using Microsoft.Bot.Builder.Dialogs;
    using Microsoft.Bot.Schema;
    using Microsoft.Extensions.Logging;
    
    namespace Microsoft.BotBuilderSamples.Bots
    {
        public class QnABot<T> : ActivityHandler where T : Microsoft.Bot.Builder.Dialogs.Dialog
        {
            protected readonly BotState ConversationState;
            protected readonly Microsoft.Bot.Builder.Dialogs.Dialog Dialog;
            protected readonly BotState UserState;
    
            public QnABot(ConversationState conversationState, UserState userState, T dialog)
            {
                ConversationState = conversationState;
                UserState = userState;
                Dialog = dialog;
            }
    
            public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default)
            {
                await base.OnTurnAsync(turnContext, cancellationToken);
    
                // Save any state changes that might have occured during the turn.
                await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);
                await UserState.SaveChangesAsync(turnContext, false, cancellationToken);
            }
    
            protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken) =>
                // Run the Dialog with the new message Activity.
                await Dialog.RunAsync(turnContext, ConversationState.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken);
    
            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)
                    {
                        await turnContext.SendActivityAsync(MessageFactory.Text($"Hola, bienvenido al ChatBot de binapps \n ¿En que te puedo ayudar?"), cancellationToken);
                    }
                }
            }
        }
    }
    

    Friday, November 15, 2019 2:25 PM
  •  

    Hi Daniel,

    Thanks for your response. There is a sample bot can help you welcome users. This bot has been created using Bot Framework, is shows how to welcome users when they join the conversation.

    Please refer to the following sample: https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/03.welcome-user

    Let us know if you have further question/ concern. Thanks.

    Regards,

    Yutong

    Saturday, November 16, 2019 12:19 PM
    Moderator