botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

How to chatbot start conversation user open chat window.

Open amolghanwat2020 opened this issue 9 years ago • 4 comments

How to chatbot take initiative for chat when user open any channel then chatbot send "Hello, How can help you?" to user ? I want above functionality in web control channel using direct line api.

amolghanwat2020 avatar Mar 02 '17 14:03 amolghanwat2020

@danmarshall @eanders-MS can you specify an initial greeting message in the new web chat control?

willportnoy avatar Mar 02 '17 22:03 willportnoy

No, this is not specified in the WebChat Control - it is created by your bot.

danmarshall avatar Mar 02 '17 22:03 danmarshall

Please Take a look at EchoBot's Controller in BotBuilder SDK . As mention, you can change the ConversationUpdate for your requirement.

case ActivityTypes.ConversationUpdate:
                        IConversationUpdateActivity update = activity;
                        using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, activity))
                        {
                            var client = scope.Resolve<IConnectorClient>();
                            if (update.MembersAdded.Any())
                            {
                                var reply = activity.CreateReply();
                                foreach (var newMember in update.MembersAdded)
                                {
                                    if (newMember.Id != activity.Recipient.Id)
                                    {
                                        reply.Text = $"Welcome {newMember.Name}!";
                                    }
                                    else
                                    {
                                        reply.Text = $"Welcome {activity.From.Name}";
                                    }
                                    await client.Conversations.ReplyToActivityAsync(reply);
                                }
                            }
                        }

SathishNeel avatar Mar 03 '17 11:03 SathishNeel

thank you @SathishNeel :)

willportnoy avatar Mar 07 '17 03:03 willportnoy