Connection
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).
- Go to the Azure Portal and sign in with your Microsoft account.
- Locate the Microsoft Entra ID service and click on it.
- Click on App registrations and then click on New registration.
- Enter a name for your application and select the Accounts in this organizational directory only option for the Supported account types field.
- Keep the Redirect URI field empty and click on Register.
- Copy the Application (client) ID and record it as the
client_idparameter, and copy the Directory (tenant) ID and record it as thetenant_idparameter. - Click on Certificates & secrets and then click on New client secret.
- Enter a description for your client secret and select an expiration period.
- Click on Add and copy the generated client secret and record it as the
client_secretparameter. - Click on Authentication and then click on Add a platform.
- Select Web and enter the following URLs in the Redirect URIs field:
https://cloud.mindsdb.com/verify-authhttp://localhost:47334/verify-auth(for local development)
Usage
Now, you can post a message to a chat:Supported Tables
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.
Chatbot
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.Step 1: Create a Microsoft Teams Data Source
As shown above, create a database with the newteams 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.
Step 2: Create an Agent
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.Step 2.1: Create a Conversational Model
Create a conversational model using either theLangChain or LlamaIndex integrations. Given below is an example of a conversational model created using the LlamaIndex integration:
Step 2.2: Create an Agent using the Conversational Model
Let’s create an agent using the conversational model created above:Step 3: Create a Chatbot
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.