How to retrieve tenant organization name from tenant ID in Microsoft Teams bot development?

I’m working with a Teams bot using the bot framework and trying to figure out how to get the actual organization name from the tenant information. When my bot processes messages, I can access the activity.channelData.tenant object through the bot context, but it only provides the tenant id field.

Let me give you an example of what I’m dealing with. Say someone from ContosoLab Corp is using my bot across different Teams channels like Sales Team, Marketing Team, and Dev Team. I can easily retrieve the names of these teams and extract the tenantId that corresponds to the “ContosoLab Corp” organization. However, I’m stuck on how to actually get the readable organization name “ContosoLab Corp” from just that tenant identifier.

Is there some API method or property in the botbuilder framework that allows me to convert a tenant ID into the human-readable organization name? Any help would be appreciated!

The Graph API works, but there’s an easier way using Bot Framework directly. Just use TeamsInfo.getTeamDetails() - it returns team info including organization details. Heads up though, this only works in team contexts, not personal chats. You can also grab organization info straight from token claims during authentication. The JWT token usually has the tenant name in tid and sometimes tenant_ctry claims. I’ve used this a lot for SSO flows. One gotcha - some orgs have custom display names that don’t match their registered names, so double-check the data matches what users expect.

you gotta use the Microsoft Graph API for that. the Bot Framework doesn’t pull the org name from the tenant ID alone. make a call to Graph’s /organization endpoint using the tenant ID, and it will give you the displayName. don’t forget to set the right Azure AD permissions!