Skip to content

MS Teams integration supports only deprecated multi tenant bots #2919

@thatdc

Description

@thatdc

Describe the bug
The current Chainlit Microsoft Teams integration appears to assume a MultiTenant Bot Framework app.
The Teams deployment documentation only mentions the following environment variables:

TEAMS_APP_ID=<app-id>
TEAMS_APP_PASSWORD=<app-secret>

However, newly created Azure/Bot Framework bots will be SingleTenant. Microsoft documentation states that new multi-tenant bot creation is no longer supported after July 31, 2025, and recommends using SingleTenant or UserAssignedMSI going forward.

For SingleTenant bots, the Bot Framework configuration requires the tenant ID as well.

In Chainlit, the Teams adapter is currently initialized without passing the tenant:

adapter_settings = BotFrameworkAdapterSettings(
    app_id=os.environ.get("TEAMS_APP_ID"),
    app_password=os.environ.get("TEAMS_APP_PASSWORD"),
)
adapter = BotFrameworkAdapter(adapter_settings)

This causes Teams messages to reach the Chainlit /teams/events endpoint correctly, but Chainlit fails when replying to Teams with:

botbuilder.schema._models_py3.ErrorResponseException: Operation returned an invalid status code 'Unauthorized'

To Reproduce
Follow the current MS Teams integration guide at https://docs.chainlit.io/deploy/teams. When it's time to create a Bot, you will notice that there is no way to select SingleTenant vs MultiTenant. New bots will be always created as SingleTenant and the field will not be editable.

Expected behavior
Chainlit should support SingleTenant Bot Framework apps by allowing the tenant ID to be configured and passed to BotFrameworkAdapterSettings.

Tested workaround/fix
Patching chainlit/teams/app.py like this fixes the issue:

adapter_settings = BotFrameworkAdapterSettings(
    app_id=os.environ.get("TEAMS_APP_ID"),
    app_password=os.environ.get("TEAMS_APP_PASSWORD"),
    channel_auth_tenant=os.environ.get("TEAMS_APP_TENANT_ID"),
)
adapter = BotFrameworkAdapter(adapter_settings)

Then running Chainlit with:

TEAMS_APP_ID=<application-client-id>
TEAMS_APP_PASSWORD=<client-secret-value>
TEAMS_APP_TENANT_ID=<directory-tenant-id>

After this change, the bot can successfully reply in Teams.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions