Heinrich Ulbricht
Heinrich Ulbricht

Reputation: 10372

MS Bot Framework: How to get user's locale in notification-only bot?

We are building a proactive bot that will be rolled out to every user via Teams policy. Upon installation of the Teams App the user shall be greeted with a localized message and will receive occasional further localized messages.

The localization is the problem.

How is the bot supposed to react to changes in the user's locale in the Teams client? Assume the user switches from English to German - how is this propagated to the bot?

I tried getting the locale via turnContext.Activity.GetLocale() but this returns null. I found hints that the locale might not be set in the "install events" the bot gets when the Teams App is installed for the user. And even if it would - this wouldn't cover locale changes by the user.

Is this a supported scenario for localization? How would a solution look? Maybe an active lookup is necessary? Any hints are appreciated.

Technical notes:

The bot saves the initial ConversationReference when being installed, then uses ContinueConversationAsync to push messages to the user. Locale is always null.

The bot is marked as "notification only", so there will never be a message from user to bot.

enter image description here

The bot will only be used in Teams. No web chat etc.

Upvotes: 1

Views: 513

Answers (1)

Prasad-MSFT
Prasad-MSFT

Reputation: 1029

This is a known limitation currently. Bot has to wait for user to message. The message activity has clientInfo filled out in channelData with locale information.

Upvotes: 1

Related Questions