docs/integrations/app-integrations/microsoft-teams.mdx
This documentation describes the integration of MindsDB with Microsoft Teams, the ultimate messaging app for your organization. The integration allows MindsDB to access data from Microsoft Teams and enhance it with AI capabilities.
Before proceeding, ensure the following prerequisites are met:
Establish a connection to Microsoft Teams from MindsDB by executing the following SQL command and providing its handler name as an engine.
CREATE DATABASE teams_datasource
WITH ENGINE = 'teams',
PARAMETERS = {
"client_id": "12345678-90ab-cdef-1234-567890abcdef",
"client_secret": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
"tenant_id": "abcdef12-3456-7890-abcd-ef1234567890"
};
Required connection parameters include the following:
client_id: The client ID of the registered Microsoft Entra ID application.client_secret: The client secret of the registered Microsoft Entra ID application.tenant_id: The tenant ID of the Microsoft Entra ID directory.Optional connection parameters include the following:
permission_mode: The type of permissions used to access data in Microsoft Teams. Can be either delegated (default) or application.Follow the instructions below to set up the Microsoft Teams app that will be used to connect with MindsDB.
<Steps> <Step title="Register an application in the Azure portal"> - Navigate to Microsoft Entra ID in the Azure portal, click on *Add* and then on *App registration*. - Click on *New registration* and fill out the *Name* and select the `Accounts in any organizational directory (Any Azure AD directory - Multitenant)` option under *Supported account types*. - If you chose the `application` permission mode you may skip this step, but if you are using `delegated` permissions, select `Web` as the platform and enter URL where MindsDB has been deployed followed by /verify-auth under *Redirect URI*. For example, if you are running MindsDB locally (on https://localhost:47334), enter https://localhost:47334/verify-auth in the Redirect URIs field. - Click on *Register*. **Save the *Application (client) ID* and *Directory (tenant) ID* for later use.** - Click on *API Permissions* and then click on *Add a permission*. - Select *Microsoft Graph* and then click on either *Delegated permissions* or *Application permissions* based on the permission mode you have chosen. - Search for the following permissions and select them: - `delegated` permission mode: - Team.ReadBasic.All - Channel.ReadBasic.All - ChannelMessage.Read.All - Chat.Read - `application` permission mode: - Group.Read.All - ChannelMessage.Read.All - Chat.Read.All - Click on **Add permissions**. - Request an administrator to grant consent for the above permissions. If you are the administrator, click on **Grant admin consent for [your organization]** and then click on **Yes**. - Click on *Certificates & secrets* under *Manage*. - Click on *New client secret* and fill out the *Description* and select an appropriate *Expires* period, and click on *Add*. - Copy and **save the client secret in a secure location.** <Tip> If you already have an existing app registration, you can use it instead of creating a new one and skip the above steps. </Tip> </Step> <Step title="Configure a MS Teams data souce in the MindsDB Editor"> - Open the MindsDB editor and create a connection to Microsoft Teams using the client ID, client secret and tenant ID obtained in the previous steps. Use the `CREATE DATABASE` statement as shown above. </Step> </Steps>Retrieve data from a specified table by providing the integration and table names:
SELECT *
FROM teams_datasource.table_name
LIMIT 10;
teams: The table containing information about the teams in Microsoft Teams.channels: The table containing information about the channels in Microsoft Teams.channel_messages: The table containing information about messages from channels in Microsoft Teams.chats: The table containing information about the chats in Microsoft Teams.chat_messages: The table containing information about messages from chats in Microsoft Teams.