Skip to content
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

Multilingual Bot - Greeting Trigger - Conversation Update Activity showing english, not the language selected #8659

Closed
3 tasks
aparnaji opened this issue Sep 13, 2021 · 5 comments
Assignees
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Required for internal reporting. Do not delete. customer-reported Required for internal Azure reporting. Do not delete. Support Type: Bug Something isn't working

Comments

@aparnaji
Copy link

aparnaji commented Sep 13, 2021

Describe the bug

Multilingual Bot - Greeting Trigger - Conversation Update Activity showing english, not the language selected
I am using en-US and hi-IN, when I send hi-IN from webchat - directline, it shows greeting trigger/ actions in english and rest all in triggers in hindi

Version

Version: 2.1.1-nightly.267886.6a6a24a
Electron: 8.2.4
Chrome: 80.0.3987.165
NodeJS: 12.13.0
V8: 8.0.426.27-electron.0

Browser

  • Chrome
  • Edge

OS

  • Windows

To Reproduce

Steps to reproduce the behavior:

  1. Go to Bot
  2. Create two triggers
  3. Trigger 1 with Greeting in English and Hindi files (both lg and lu files)
  4. Trigger 2intent recognized trigger English and Hindi files (both lg and lu files)
    window.WebChat.renderWebChat(
    {
    directLine: window.WebChat.createDirectLine({
    token: 'xxxxxx'
    }),
    userID: 'WebChat_UserId',
    locale: 'hi-IN',
    username: 'Web Chat User',
    // locale: 'en-US',
    // Passing 'styleSet' when rendering Web Chat
    styleSet
    },
    document.getElementById('webchat')

Expected behavior

Greeting should show in english if locale is english and else hindi
But it always shows english irrespective of the locale selected

Screenshots

Additional context

It happens only with Directline webchat , if you test through emulator it works fine

@aparnaji aparnaji added Needs-triage A new issue that require triage Type: Bug Something isn't working labels Sep 13, 2021
@tonyanziano
Copy link
Contributor

Thanks for reporting this issue @aparnaji .

This is a known issue with Web Chat. Emulator manages the locale so that's why the expected behavior is observed when using Emulator, however the Direct Line channel does not know the locale at the time of initializing the conversation and sending the conversation update to the bot.

As a workaround, you can try implementing a custom welcome message event as demonstrated in this sample:

https://github.com/microsoft/BotFramework-WebChat/tree/main/samples/04.api/a.welcome-event

@tonyanziano tonyanziano added Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-reported Required for internal Azure reporting. Do not delete. Support and removed Needs-triage A new issue that require triage labels Sep 14, 2021
@tonyanziano
Copy link
Contributor

@stevkan can you please keep an eye on this?

@tonyanziano tonyanziano added the customer-replied-to Required for internal reporting. Do not delete. label Sep 14, 2021
@aparnaji
Copy link
Author

aparnaji commented Sep 15, 2021

Thanks for update, Issue that I have is only the greeting dialog has this issue subsequent dialogues are coming in right locale. I tried with the code that u shared and I am having the same issue

@stevkan
Copy link
Collaborator

stevkan commented Sep 20, 2021

@aparnaji, test if this option works for you. In my own testing, it works. FYI, this assumes you have implemented the custom welcome message event referenced above in the 'a.welcome.event' sample.

  1. In the Greeting trigger (ConversationUpdate activity), remove or disable all actions within it
  2. Add an Event received trigger (Event activity)
  3. In the event trigger:
    a. Click add an action
    b. Select Create a condition
    c. Choose 'Branch: If/else'
    d. In the Condition field, enter turn.activity.name == "webchat/join"
  4. Under True of the 'Branch: If/else':
    a. Click add an action
    b. Select Create a condition
    c. Choose 'Branch: Switch (multiple options)'
    d. In the Condition field, enter turn.activity.locale
  5. Under Cases, add a Value for 'hi-IN' and 'en-US'
  6. For each case, add the action(s) you want to have happen there (i.e. the type of greetings you want displayed)

At this point, when Web Chat establishes a connection to Direct Line, the bot will still receive the conversationUpdate. Since the code contained within that trigger was disabled/removed, the bot will essentially skip it.

Once the connection to Direct Line has completed, Web Chat will fire off an event activity with the name value of webchat/join and a value of window.navigator.language. Note: the 'a.welcome-event' sample sends an event with a payload value of { window.navigator.language }. I chose NOT to send it as an object and, instead, just sent the string.

The bot, looking for a specific event that has the locale defined in the value property, will filter on the locale displaying the appropriate greeting message, as a result.

image

@stevkan
Copy link
Collaborator

stevkan commented Sep 29, 2021

Closing as resolved.

@stevkan stevkan closed this as completed Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Required for internal reporting. Do not delete. customer-reported Required for internal Azure reporting. Do not delete. Support Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants