Localization and Multi-Tenant Support|Mastering Microsoft Teams Bots 4.4
4.4 Localization and Multi-Tenant Support
You’ve built a helpful, interactive, and intelligent bot — congratulations. But what happens when someone in Tokyo opens it and sees messages in English they don’t understand? Or when a second company installs your bot and their data starts mixing with someone else’s?
This is where localization and multi-tenant support enter the picture. These aren’t advanced features — they’re table stakes for real-world deployments. If you want your bot to live in production, especially in enterprise environments, it must speak the user’s language and keep tenants (organizations) completely isolated.
4.4.1 Localization: Speak the User’s Language
Microsoft Teams users can set their preferred language. Your bot should be able to respond accordingly — both in static text (like button labels) and in dynamic responses.
Detecting User Locale
Every activity from Teams includes a locale field (e.g., en-US, fr-FR, ja-JP).
// Node.js
const userLocale = context.activity.locale || "en-US";
You can use this to dynamically load localized strings from a file or service.
Using Resource Files
A good pattern is to use separate translation files (e.g., JSON, .resx, or a localization library) for each supported language.
// en.json
{ "greeting": "Hello, how can I help you today?" }
// ja.json
{ "greeting": "こんにちは。本日どのようにお手伝いできますか?" }
Then, when building responses:
const strings = loadStringsForLocale(userLocale);
await context.sendActivity(strings.greeting);
Pro Tip:
Always include a fallback (usually English) and test in dark mode, RTL (right-to-left), and mobile contexts if you're aiming for international adoption.
4.4.2 Multi-Tenant Support: Serving More Than One Organization
In Microsoft Teams, each tenant represents a unique organization. If your bot will be used by multiple tenants (e.g., across different companies), it must store and handle data separately per tenant.
When your bot receives an activity, the tenant ID is included:
const tenantId = context.activity.conversation.tenantId;
Use this to:
- Partition your data per organization (e.g., by tenantId in your database)
- Assign organization-specific settings, permissions, or branding
- Prevent cross-tenant data access or leakage
4.4.3 Where It Gets Tricky
Supporting multiple tenants also means supporting multiple Azure AD app consents. When your bot uses Microsoft Graph or protected APIs, each tenant admin must grant access. You may need to:
- Provide a per-tenant onboarding flow
- Handle consent rejection or revocation gracefully
- Store tokens or auth settings scoped to the tenant
4.4.4 Best Practices
- 🏷️ Always tag all user and resource data with
tenantIdin your storage - 🌍 Build a string lookup system for localization early — don’t hardcode messages
- 🔐 Treat each tenant like a separate world: don’t mix configuration, files, or messages
- 📘 Consider hosting a separate "admin portal" for tenant onboarding and management
4.4.5 Summary
Your bot is no longer a prototype. Supporting localization and multi-tenancy means you're building for scale, inclusion, and security. These aren’t features to add later — they’re decisions to make now, with care.
In the next section, we’ll begin our transition toward deployment — starting with getting your bot into Azure and preparing for production rollout.
Shohei Shimoda
I organized and output what I have learned and know here.タグ
検索ログ
Development & Technical Consulting
Working on a new product or exploring a technical idea? We help teams with system design, architecture reviews, requirements definition, proof-of-concept development, and full implementation. Whether you need a quick technical assessment or end-to-end support, feel free to reach out.
Contact Us