Botframework-webchat: Welcome Message from Bot language

Created on 12 Jul 2017  ·  8Comments  ·  Source: microsoft/BotFramework-WebChat

Hello,
I send the user a welcome message when the conversation is updated. The string for this message comes from a ressource file. The message is available in English and German, but the bot always sends the welcome message in English. With the following messages the bot always uses the right language, depending on the browser settings. Is it possbile to also get the first message in the right language?

Most helpful comment

I would guess the problem is that the user locale (like the user name) is only sent to the bot with a user message. @dandriscoll it would be nice to send these when starting the conversation.

As a workaround, you can use the backchannel to send the an event containing the locale to the bot.

All 8 comments

I would guess the problem is that the user locale (like the user name) is only sent to the bot with a user message. @dandriscoll it would be nice to send these when starting the conversation.

As a workaround, you can use the backchannel to send the an event containing the locale to the bot.

@20112077 Hi,
Can you send the welcome message on web chat ?

@GaiaAnn Hi,
The welcome message is working on webchat, I send the message with this code:

  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
                if (message.MembersAdded.Any(o => o.Id == message.Recipient.Id))
                {
                    var reply = message.CreateReply("Welcome");
                    ConnectorClient connector = new ConnectorClient(new Uri(message.ServiceUrl));
                    await connector.Conversations.ReplyToActivityAsync(reply);
                }
            }

Thanks for your reply.
I'll try this!

Alexander Spöcker notifications@github.com 於 2017年7月14日 下午4:26 寫道:

@GaiaAnn Hi,
The welcome message is working on webchat, I send the message with this code:
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 if (message.MembersAdded.Any(o => o.Id == message.Recipient.Id)) { var reply = message.CreateReply("Welcome"); ConnectorClient connector = new ConnectorClient(new Uri(message.ServiceUrl)); await connector.Conversations.ReplyToActivityAsync(reply); } }


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Same problem for me. Sending the welcome message is possible with ConversationUpdate but only in one language.

@billba : using backchannel didn't help me because I didn't managed to send a response message to a backchannel incoming event, is this something possible ? And if I only try to use the backchannel event to store the user language in context, it's not working either as the ConversationUpdate is happening before the backchannel activity that set the language.

Did somebody find something to have a localized welcome message?
Thanks.

@coronag you can try this:

   else if (activity.Type == ActivityTypes.Event && activity.Name == "setLanguage")
            {
                if(activity.Value.ToString().ToLower() == "en")
                {
                    language = CultureInfo.GetCultureInfo("EN");
                }
                else
                {
                    language = CultureInfo.GetCultureInfo("DE");
                }
                await SayHi(activity);
            }
private async Task SayHi(Activity message)
        {
            Thread.CurrentThread.CurrentUICulture = language;
            var reply = message.CreateReply();
            var heroCard = new ThumbnailCard();
            heroCard.Title = Resources.Text
            heroCard.Text = Resources.Text1;
            heroCard.Images = new List<CardImage> { new CardImage("url to Image") };
            var attachment = heroCard.ToAttachment();
            reply.Attachments.Add(attachment);
            ConnectorClient connector = new ConnectorClient(new Uri(message.ServiceUrl));
            await connector.Conversations.ReplyToActivityAsync(reply);
            return;
        }

Thanks !
Thumbnail card seems to work, is it possible to do the same without a card, only text ?
Just Find out using reply.Text instead... Many Thanks.

Closing, can be tracked over on #1371

Was this page helpful?
0 / 5 - 0 ratings

Related issues

prashanthsridhar picture prashanthsridhar  ·  3Comments

GewoonMaarten picture GewoonMaarten  ·  3Comments

compulim picture compulim  ·  3Comments

mmalaiarasan-conga picture mmalaiarasan-conga  ·  3Comments

corinagum picture corinagum  ·  3Comments