-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to greet on Web Chat i.e Greet message from Bot to User #2098
Comments
We are using conversationUpdated activity to send a message to the user. Check out our demo bot here http://alboteinstein.azurewebsites.net/index.html CC: @Kothakapu |
ConversationUpdate does not seem to work for me in web chat. It used to work few days back , suddenly stoped working. |
Below is the code:
|
Hi @AnandChitale, with a few small changes I was able to get your code working in my testbot (Microsoft.Bot.Builder v3.5.0): case ActivityTypes.ConversationUpdate:
IConversationUpdateActivity update = activity;
using (var scope = Microsoft.Bot.Builder.Dialogs.Internals.DialogModule.BeginLifetimeScope(Conversation.Container, activity))
{
var client = scope.Resolve<IConnectorClient>();
if (update.MembersAdded.Any())
{
foreach (var newMember in update.MembersAdded)
{
if (newMember.Id != activity.Recipient.Id)
{
var reply = activity.CreateReply();
reply.Text = $"Welcome {newMember.Name}!";
await client.Conversations.ReplyToActivityAsync(reply);
}
}
}
}
break; For some reason I was having a problem compiling Does the above code work for you? Is your |
Yes it used to work before. Suddenly stopped working i.e Bot was not able to greet user on conversation update. But when user types Hi ,then bot replied with greet message. |
@abhishan Could you please share if how to have greet message using Web Chat. |
@AnandChitale, were you able to figure this out? |
No still facing the same issue.. Bot does not greet when web chat link in opened in any browser. only when user say hi , Bot greets.. @Andrea-Orimoto do you have any solution.. |
@AnandChitale Your screenshot above shows the old WebChat control. Are you using, or have you tried using, the new Web Chat control? You must opt in to it on the WebChat channel's config page. It might be that ConversationUpdate messages are not working in the old control. I will look into this, but in the meantime you might try using the new WebChat. It has better support for more media types and other improvements. |
Yes the ConversationUpdate messages are not working in my case for web chat neither in directline. |
Hello, Any luck on the above yet? I tried using the new web chat control as well as a customized version built using the open source web chat. I am trying to display a welcome card (Hero card). This works fine in the emulator however doesnt work when published - neither in the classic web chat control nor in my customized version configured using direct line. The conversation update doesnt get called for me as soon as the bot gets launched. Instead I see the welcome card getting displayed after the user types in some text. Not sure if i am missing something. else if (message.Type == ActivityTypes.ConversationUpdate)
{
// Handle conversation state changes, like members being added and removed
// Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
// Not available in all channels
IConversationUpdateActivity update = message;
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
{
var client = scope.Resolve();
ConnectorClient connector = new ConnectorClient(new Uri(message.ServiceUrl));
if (update.MembersAdded.Any())
{
var replyNow = message.CreateReply();
foreach (var newMember in update.MembersAdded)
{
if (newMember.Id != message.Recipient.Id)
{
List cardImages = new List();
string strCurrentURL = this.Url.Request.RequestUri.AbsoluteUri.Replace(@"/api/messages", "");
string imageURL = String.Format(@"{0}/{1}", strCurrentURL, "Images/icon_Hamilton_1.png");
cardImages.Add(new CardImage(url: imageURL));
string subtitle = "";
subtitle = @"Welcome!";
HeroCard plCard = new HeroCard()
{
Title = "HHHHH",
Subtitle = subtitle,
Images = cardImages,
Buttons = null
};
Attachment plAttachment = plCard.ToAttachment();
List alist = new List();
alist.Add(plAttachment);
replyNow.Attachments = alist;
connector.Conversations.ReplyToActivityAsync(replyNow);
}
}
}
}
} I seem to be kind of stuck here and any help or debugging tips are much appreciated please! |
@AnithaJothi . I am still facing this issue both on web chat and directline. For directline the workaround is to send a private message to bot and handle the response as greet. Do not show private message on the UI. On Web Chat , Yes the bot responds only when user inputs something. |
I am using WebChat control, hosted in website. ConversationUpdate() gets fired twice. So I always greet user twice, which is so annoying. Can any one tell me , how to fix this? Code snippet:
|
Plus I am trying to trigger a dialog right after my greeting message, But I have to force user to type something, then only Post would get called. Is there any workaround for this? |
@AnandChitale Are you still experiencing the issue after upgrading to BotBuilder 3.8.1? |
@nils I am not facing this issue now. Thanks!
…On Thu, May 25, 2017 at 5:33 AM, Nils ***@***.***> wrote:
@AnandChitale <https://github.com/anandchitale> Are you still
experiencing the issue after upgrading to BotBuilder 3.8.1
<https://www.nuget.org/packages/Microsoft.Bot.Builder/>?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2098 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AXK431yysKmA39gjgVcaFGYAA2Gdet-Mks5r9MU8gaJpZM4Lr_JH>
.
|
Hello Guys,
|
@rohantare The ConversationUpdate activity is sent for each member added: once for the user, and once for the bot. Filtering on .Recipient.Id enables replying just once: else if (message.GetActivityType() == ActivityTypes.ConversationUpdate)
{
IConversationUpdateActivity iConversationUpdated = message as IConversationUpdateActivity;
if (iConversationUpdated != null)
{
ConnectorClient connector = new ConnectorClient(new System.Uri(message.ServiceUrl));
foreach (var member in iConversationUpdated.MembersAdded ?? System.Array.Empty<ChannelAccount>())
{
// if the bot is added, then
if (member.Id == iConversationUpdated.Recipient.Id)
{
var reply = ((Activity)iConversationUpdated).CreateReply($"Hey I am a chatbot");
await connector.Conversations.ReplyToActivityAsync(reply);
}
}
}
} @chetanmekha Similarly, in node: bot.on('conversationUpdate', function (message) {
if (message.membersAdded) {
message.membersAdded.forEach(function (identity) {
if (identity.id === message.address.bot.id) {
bot.send(new builder.Message()
.address(message.address)
.text("Hello! I'm a bot."));
}
});
}
}); |
@EricDahlvang your solution works for me (NodeJS) but the welcome message shows every refresh of the page and not just the first time the user sends a message. |
@sahar922 When the page is refreshed, a new conversation is initiated. If you want to sign users in before starting a conversation, you would need to write a client that handles that logic. |
@EricDahlvang Do you have any example? documentation to read? Thanks! |
@sahar922 I do not have an example demonstrating the fact that a new conversation is initiated when the page is refreshed. You can hit F12 in your browser, on a page using the WebChat control, and look at network activity. The WebChat control https://github.com/Microsoft/BotFramework-WebChat uses DirectLineJs https://github.com/Microsoft/BotFramework-WebChat . If you follow what occurs when calling BotChat.App, you'll see that a new conversation is initiated for the supplied userid. If you wish to discuss this further, please open a new issue or ask a question on Stack Overflow. Issue 2098 is currently closed. |
Deployed a bot to Azure.
![greet](https://cloud.githubusercontent.com/assets/24295647/22239636/86f61f92-e23d-11e6-9f19-60c7f27343f1.png)
Enabled Web Chat Channel.
Embed it to a iFrame on a website.
Question: Ho
w to get greet message from bot to user as in attached file.
The text was updated successfully, but these errors were encountered: