Reputation: 607
I am currently implementing localization within my bot, and I have it working on multiple channels using Bot Framework v4.
In Skype and Teams channels, the locale comes thru as ChannelData, however, on Facebook, I do not see the locale.
If I change the language in Facebook settings to non-English, the locale is still not passed in.
currently, the only way I can determine the locale is by auto-detecting the language from the utterance from the user.
How do I get the locale to work with Facebook Messenger bot?
Upvotes: 1
Views: 249
Reputation: 3024
Facebook Messenger doesn't include the locale
in the message payload, so this is not present in the channelData
property.
You can receive the locale
of an user by querying the User Profile API. Please note that you need to have pages_user_locale
permissions in order to query the locale field.
A way to solve this is to create a middleware that queries the API for every new message where channel is Facebook. Afterwards you save the locale in the userState and apply it to the incoming message, so your bot code doesn't have to be changed. In your middleware you can build some logic to retrieve the locale from the state, instead of querying it on every new message.
Upvotes: 3