In this section, we present how to connect Microsoft Teams to MindsDB.
Microsoft Teams is the ultimate messaging app for your organization—a workspace for real-time collaboration and communication, meetings, file and app sharing, and even the occasional emoji! All in one place, all in the open, all accessible to everyone.
The Microsoft Teams handler allows you to read and send messages to a Microsoft Teams channel or chat. It also allows you to create a chatbot that will respond to messages.
Before proceeding, ensure the following prerequisites are met:
This handler was implemented using msal for authentication and Requests to submit requests to the Microsoft Graph API.
The Microsoft Teams handler is initialized with the following parameters:
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 registered Microsoft Entra ID application.Microsoft Entra ID was previously known as Azure Active Directory (Azure AD).
The parameters given above can be obtained by registering an application in Entra ID by following these steps,
client_id
parameter, and copy the Directory (tenant) ID and record it as the tenant_id
parameter.client_secret
parameter.https://cloud.mindsdb.com/verify-auth
http://localhost:47334/verify-auth
(for local development)You can find more information about creating app registrations here.
To connect to Microsoft Teams using MindsDB, the following CREATE DATABASE statement can be used:
When the above is statement is executed with the given parameters, the handler will open a browser window and prompt you to sign in with your Microsoft account.
The handler will then act (via the app registration) as the signed in user and will submit requests to the Microsoft Graph API. This is done using the concept of delegated permissions.
Now, you can post a message to a chat:
You can also do the same for channels:
The following tables are supported by the Microsoft Teams handler:
chats
: chats that the signed in user is a member of.chat_messages
: messages sent to the signed in user’s chats.channels
: channels that the signed in user is a member of.channel_messages
: messages sent to the signed in user’s channels.While the Microsoft Teams handler allows you to read/send messages to a chat or channel as shown above, it is also possible to create a chat bot that will listen to messages sent to a chat or channel and respond to them.
As shown above, create a database with the new teams
engine by passing in the required parameters:
The chat bot will assume the identity of the user who signed in with their Microsoft account when the database was created.
An agent is created by combining a conversational model, like LlamaIndex, with a set of Skills.
Here, we will create an agent without any skills, however, it is possilbe to create agents with skills such as the ability to answer questions from a knowledge base.
Create a conversational model using either the LangChain
or LlamaIndex
integrations. Given below is an example of a conversational model created using the LlamaIndex
integration:
Let’s create an agent using the conversational model created above:
Finally, create a chatbot using the agent and the Microsoft Teams data source created above:
The enable_dms
parameter is optional and is the initially supported mode of talking to a chatbot. A chatbot responds to direct messages.