Elastic Microsoft Teams connector reference
The Microsoft Teams connector is written in Python using the Elastic connector framework.
View the source code for this connector (branch main, compatible with Elastic 9.6).
This connector is available as a self-managed connector.
This self-managed connector is compatible with Elastic versions 9.6.0+.
To use this connector, satisfy all self-managed connector prerequisites.
This connector is in technical preview and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Technical preview features are not subject to the support SLA of official GA features.
To create a new Microsoft Teams connector:
- In the Kibana UI, search for "connectors" using the global search field and choose the "Elasticsearch" connectors.
- Follow the instructions to create a new Microsoft Teams self-managed connector.
You can use the Elasticsearch Create connector API to create a new self-managed Microsoft Teams self-managed connector.
For example:
PUT _connector/my-microsoft_teams-connector
{
"index_name": "my-elasticsearch-index",
"name": "Content synced from Microsoft Teams",
"service_type": "microsoft_teams"
}
You’ll also need to create an API key for the connector to use.
The user needs the cluster privileges manage_api_key, manage_connector and write_connector_secrets to generate API keys programmatically.
To create an API key for the connector:
Run the following command, replacing values where indicated. Note the
encodedreturn values from the response:POST /_security/api_key{ "name": "connector_name-connector-api-key", "role_descriptors": { "connector_name-connector-role": { "cluster": [ "monitor", "manage_connector" ], "indices": [ { "names": [ "index_name", ".search-acl-filter-index_name", ".elastic-connectors*" ], "privileges": [ "all" ], "allow_restricted_indices": false } ] } } }Update your
config.ymlfile with the API keyencodedvalue.
Refer to the Elasticsearch API documentation for details of all available Connector APIs.
To use this connector as a self-managed connector, use the Microsoft Teams tile from the connectors list Customized connector workflow.
For additional operations, see Connectors UI in Kibana.
The connector connects to Microsoft Teams using application credentials (client secret or certificate), the same approach as SharePoint Online and Outlook. You do not need to install a Teams app in every team or chat.
When document level security (DLS) is enabled, search results are restricted to users who belong to the relevant team, channel, or chat. The connector application itself can read content according to the permissions you grant below.
To connect to Microsoft Teams, register an application in Microsoft Entra ID and grant it the required Microsoft Graph application permissions. Follow these steps:
In the Microsoft Entra admin center, register a new application (confidential client).
Record the Directory (tenant) ID and Application (client) ID.
Create either:
- a client secret (Certificates & secrets → New client secret), or
- a certificate (upload a certificate and keep the matching private key).
Under API permissions, add and grant admin consent for the following Microsoft Graph application permissions:
Team.ReadBasic.All— read teams in your organizationTeamMember.Read.All— read who belongs to each teamUser.ReadBasic.All— read user profilesChannel.ReadBasic.All— read channelsChannelMember.Read.All— read who can access each channelChannelMessage.Read.All— read channel messages and repliesChat.Read.All— read chats, messages, and repliesFiles.Read.All— read file attachments (required when Fetch attachment content is enabled)
Click Grant admin consent to approve the permissions. This step requires administrative privileges. If you are not an admin, request that an admin grant consent via the Entra admin center.
The connector requires application permissions. It does not support delegated permissions (scopes) or username/password authentication.
ChannelMessage.Read.All and Chat.Read.All are protected Teams APIs. Admin consent alone may not be enough — some tenants also need Microsoft to approve access for your application before message content can be read.
The following configuration fields are available:
tenant_id(required)-
Unique identifier for your Microsoft Entra tenant. Example:
123a1b23-12a3-45b6-7c8d-fc931cfb448d
client_id(required)-
Unique identifier for your Entra application. Example:
ab123453-12a2-100a-1123-93fd09d67394
auth_method(required)-
Authentication method to use with Microsoft Graph. Options:
secret(default) — authenticate with a client secret.certificate— authenticate with a certificate and private key.
secret_value-
(required if
auth_methodissecret) Client secret value from the Certificates & secrets tab of your Entra application. Example:eyav1~12aBadIg6SL-STDfg102eBfCGkbKBq_Ddyu
certificate- (required if
auth_methodiscertificate) Content of the certificate file uploaded to your Entra application. private_key- (required if
auth_methodiscertificate) Content of the private key file that matches the uploaded certificate. fetch_attachment_content- Toggle to index files from channel folders and message attachments, and extract their content. Requires the
Files.Read.Allapplication permission. Default value istrue. use_text_extraction_service- Toggle to enable the self-managed local extraction service for file content. Requires that ingest pipeline settings disable text extraction. Default value is
false. use_document_level_security-
Toggle to enable document level security (DLS). When enabled:
- Full syncs fetch access control lists for each document and store them in the
_allow_access_controlfield. - Access control syncs fetch users' access control lists and store them in a separate index.
Default value is
false. - Full syncs fetch access control lists for each document and store them in the
You can deploy the Microsoft Teams connector as a self-managed connector using Docker. Follow these instructions.
Step 1: Download sample configuration file
Download the sample configuration file. You can either download it manually or run the following command:
curl https://raw.githubusercontent.com/elastic/connectors/main/app/connectors_service/config.yml.example --output ~/connectors-config/config.yml
Remember to update the --output argument value if your directory name is different, or you want to use a different config file name.
Step 2: Update the configuration file for your self-managed connector
Update the configuration file with the following settings to match your environment:
elasticsearch.hostelasticsearch.api_keyconnectors
If you’re running the connector service against a Dockerized version of Elasticsearch and Kibana, your config file will look like this:
# When connecting to your cloud deployment you should edit the host value
elasticsearch.host: http://host.docker.internal:9200
elasticsearch.api_key: <ELASTICSEARCH_API_KEY>
connectors:
-
connector_id: <CONNECTOR_ID_FROM_KIBANA>
service_type: microsoft_teams
api_key: <CONNECTOR_API_KEY_FROM_KIBANA>
- Optional. If not provided, the connector will use the elasticsearch.api_key instead
Using the elasticsearch.api_key is the recommended authentication method. However, you can also use elasticsearch.username and elasticsearch.password to authenticate with your Elasticsearch instance.
Note: You can change other default configurations by simply uncommenting specific settings in the configuration file and modifying their values.
Step 3: Run the Docker image
Run the Docker image with the Connector Service using the following command:
docker run \
-v ~/connectors-config:/config \
--network "elastic" \
--tty \
--rm \
docker.elastic.co/integrations/elastic-connectors:9.5.2 \
/app/bin/elastic-ingest \
-c /config/config.yml
Refer to DOCKER.md in the elastic/connectors repo for more details.
Find all available Docker images in the official registry.
We also have a quickstart self-managed option using Docker Compose, so you can spin up all required services at once: Elasticsearch, Kibana, and the connectors service. Refer to this README in the elastic/connectors repo for more information.
Refer to Content extraction.
The connector syncs the following content from Microsoft Teams:
- Teams
- Channels
- Channel messages (including thread replies)
- Chats (one-on-one, group, and meeting chats), including messages and thread replies
- Users from your Microsoft Entra directory
- Files (when Fetch attachment content is enabled): files from channel folders and message attachments
Private and shared channels are included. Each file is indexed once, even when it appears in a channel folder and as a message attachment.
- Content from files bigger than 10 MB won’t be extracted by default. Use the self-managed local extraction service to handle larger binary files.
- Permissions are not synced by default. Enable document-level security (DLS) to sync permissions. Otherwise, all documents indexed to an Elastic deployment will be visible to all users with access to that Elastic Deployment.
- If the connector is missing required permissions, the sync fails rather than indexing an incomplete set of content.
Applies when upgrading to 9.6.0+ from a Microsoft Teams connector that used username/password or delegated Graph authentication.
If you already have a legacy Microsoft Teams connector or index, prefer deleting the old connector and index and creating a new connector with a fresh index. That avoids leftover documents from the previous connector (calendars, tabs, meeting recordings, and other content types that are no longer synced).
If you upgrade in place, the first successful full sync removes documents the new connector no longer produces, including:
- calendars
- channel and chat tabs
- meeting recordings
- legacy team member records (replaced by user profiles)
After upgrading, reconfigure the connector for application-only authentication (client secret or certificate). Username and password fields are no longer supported.
Calendars, meeting recordings, and tabs are no longer synced by this connector. Use the Outlook connector for calendars and the SharePoint Online connector for SharePoint-hosted meeting recordings.
Full syncs are supported by default for all connectors.
This connector does not support incremental syncs.
Document level security (DLS) enables you to restrict access to documents based on a user's permissions. Refer to configuration on this page for how to enable DLS for this connector.
When DLS is enabled, users only see Teams, channels, chats, messages, and files they have access to in Microsoft Teams. User profile documents from your directory are not restricted by DLS.
Refer to DLS in Search Applications to learn how to ingest data from a connector with DLS enabled, when building a search application. The example uses SharePoint Online as the data source, but the same steps apply to every connector.
Basic sync rules are identical for all connectors and are available by default.
Advanced sync rules are not available for this connector in the present version.
The connector framework enables operators to run functional tests against a real data source. Refer to Connector testing for more details.
To perform E2E testing for the Teams connector, run the following command:
$ make ftest NAME=microsoft_teams
For faster tests, add the DATA_SIZE=small flag:
make ftest NAME=microsoft_teams DATA_SIZE=small
- Messages in one-on-one chats for Chat with Self users are not fetched via Graph APIs. Therefore, these messages won’t be indexed into Elasticsearch.
Refer to Known issues for a list of known issues for all connectors.
See Troubleshooting.
See Security.