SOLVED

How to Get MS Teams Locale while Adding bot to MS Teams

%3CLINGO-SUB%20id%3D%22lingo-sub-3034045%22%20slang%3D%22en-US%22%3EHow%20to%20Get%20MS%20Teams%20Locale%20while%20Adding%20bot%20to%20MS%20Teams%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3034045%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Team%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhile%20users%20adding%20a%20bot%20in%20my%20MS%20Teams%2C%20we%20need%20to%20send%20a%20welcome%20card%20based%20on%20the%20Locale.%3CBR%20%2F%3EWhile%20the%20bot%20has%20been%20added%20to%20the%20user%2C%20OnMembersAddedAsync()%20has%20been%20triggered.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Estring%20userLocale%20%3D%20turnContext.Activity.GetLocale()%3B%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20returning%20the%20null%20value.%20Could%20you%20please%20suggest%2C%20how%20to%20fix%20this%20issue%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20Advance!!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3034045%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3034091%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20Get%20MS%20Teams%20Locale%20while%20Adding%20bot%20to%20MS%20Teams%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3034091%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1023459%22%20target%3D%22_blank%22%3E%40maheshkumargunasekaran%3C%2FA%3E%26nbsp%3B-%20As%20the%20bot%20activity%20is%20not%20initiated%20by%20the%20user%20action%20such%20as%20sending%20message.%20The%20bot%20doesn't%20received%20any%20locale%20information%20and%20this%20is%20by%20design%20and%20there%20is%20no%20fix%20for%20it.%20Once%20user%20sends%20a%20message%20or%20interact%20with%20the%20bot%20you%20can%20store%20this%20information%20for%20further%20interactions.%20%3CBR%20%2F%3E%3CBR%20%2F%3EAlso%20you%20can%20have%20default%20locale%20based%20on%20the%20area%20where%20application%20is%20being%20used.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThanks%2C%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EHunaid%20L%20Hanfee%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E------------------------------------------------------------------%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIf%20the%20response%20is%20helpful%2C%20please%20click%20%22**Mark%20as%20Best%20Response**%22%20and%20like%20it.%20You%20can%20share%20your%20feedback%20via%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FDevSupportFeedback)%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EMicrosoft%20Teams%20Developer%20Feedback%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Blink.%20Click%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FDevCommunityEscalationForm%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehere%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bto%20escalate.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi Team,

 

While users adding a bot in my MS Teams, we need to send a welcome card based on the Locale.
While the bot has been added to the user, OnMembersAddedAsync() has been triggered.

 

But string userLocale = turnContext.Activity.GetLocale(); is returning the null value. Could you please suggest, how to fix this issue?

 

Thanks in Advance!!!

1 Reply
best response confirmed by ChetanSharma-msft (Microsoft)
Solution

@maheshkumargunasekaran - As the bot activity is not initiated by the user action such as sending message. The bot doesn't received any locale information and this is by design and there is no fix for it. Once user sends a message or interact with the bot you can store this information for further interactions.

Also you can have default locale based on the area where application is being used.

Thanks, 

Hunaid L Hanfee

------------------------------------------------------------------

If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate. 

We support Ukraine and condemn war. Push Russian government to act against war. Be brave, vocal and show your support to Ukraine. Follow the latest news HERE