0
votes

I have two luis app with multi cultural (languages) and have a bot framework webchat on the site, how can I catch browser language to use the luis app? For example if I am using the browser in German then I want to use German Luis and if English then English luis .

1

1 Answers

0
votes

Use backchannel to send navigator language to your bot and store this information in your context on the bot side.

Then use this stored information for your LUIS calls.

See this sample: https://github.com/microsoft/BotFramework-WebChat/blob/master/samples/15.d.backchannel-send-welcome-event/README.md

They are passing the navigator language in the event:

const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
  if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
    // When we receive DIRECT_LINE/CONNECT_FULFILLED action, we will send an event activity using WEB_CHAT/SEND_EVENT
    dispatch({
      type: 'WEB_CHAT/SEND_EVENT',
      payload: {
        name: 'webchat/join',
        value: { language: window.navigator.language }
      }
    });
  }

On your bot side, catch the info:

if (turnContext.Activity.Type == ActivityTypes.Event)
{
    if (turnContext.Activity.Name == "webchat/join")
    {
        // HERE, USE THE VALUE PASSED
    }
}