> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cotool.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Teams Integration

> Chat with Cotool, approve agent actions and let agents post in Microsoft Teams

The Microsoft Teams integration adds the Cotool app to Teams. People message it or @mention it to start a chat, approve or reject agent actions from a channel, and agents post through it.

It is a separate integration from Microsoft Graph. Connecting it adds the Cotool app to your organization's Teams app catalog and installs it for you; you then pick the teams it joins from Cotool. Nobody uploads anything.

> [!NOTE]
>
> Sending alerts and other notifications to a Teams channel through a
> Workflows webhook still works as before and does not need this integration.
> See [Notifications](https://docs.cotool.ai/settings/notifications.md).

## Features

> [card] Direct messages
>
> Message the Cotool app to start a personal chat. It answers in the same chat.

> [card] Channel mentions
>
> @mention Cotool in a channel or group chat. It answers in the thread, and
> later mentions in that thread continue the chat.

> [card] Approvals
>
> Post approval requests to a channel with Approve and Reject buttons.

> [card] Agent messages
>
> Agents send messages to the channels and chats the app is in. Each ends with an **Open in Cotool** link to the chat or agent run it came from.

## Setup

**1. Connect as a Teams administrator**

Go to **Settings > Integrations** in Cotool, find **Microsoft Teams** and click **Connect**. A Teams administrator or global administrator approves Cotool for the organization, then signs in once more. Cotool adds its app to your Teams app catalog and installs it for that administrator.

**2. Pick the teams**

Cotool returns to the integration's page. Under **Teams**, select the teams Cotool should work in and click **Add Cotool**, then sign in with Microsoft as an owner of those teams or a Teams administrator. Come back to the page later to add more. Anyone allowed to use custom apps can open a direct chat with Cotool from the Teams app list, or add it to a group chat.

> [!NOTE]
>
> If your Teams admin center blocks custom apps, allow the Cotool app under
> **Teams apps > Manage apps** before people use it.

### Permissions

The administrator's approval grants these Microsoft Graph permissions:

| Permission | Why |
| - | - |
| `AppCatalog.ReadWrite.All` (delegated) | Add the Cotool app to your catalog, and update it later |
| `TeamsAppInstallation.ReadWriteAndConsentSelfForUser` (delegated) | Install the Cotool app, and only that app, for the person who connects |
| `TeamsAppInstallation.ReadWriteAndConsentSelfForTeam` (delegated) | Add the Cotool app, and only that app, to the teams you pick |
| `Team.ReadBasic.All` | List your teams so you can pick where Cotool goes |
| `TeamsAppInstallation.ReadWriteAndConsentSelfForTeam.All` | See which teams have the Cotool app, and remove it from one |
| `Sites.Selected` | Read files in SharePoint sites you grant later. It gives no access until you grant a site |

Delegated permissions act only as the person signed in, and only while they sign in: Cotool doesn't keep their Microsoft sign-in.

Adding Cotool to a team also grants the app resource-specific permissions in that team only: reading its channel messages and channel settings.

## Who can use it

Cotool matches each person in Teams to a Cotool user by the email address Microsoft Entra holds for them. Someone without a Cotool account in your organization gets a reply saying so, and nothing runs.

A chat belongs to the person who started it. In a channel thread, only that person can continue the chat; anyone else can @mention Cotool in a new post to start their own.

## Direct messages

A direct chat with Cotool continues one Cotool chat, so follow-up questions keep their context. Send `new chat` to start over. A chat left idle for 12 hours also starts over on its next message.

## Channel mentions

In a channel or group chat, Cotool only reads messages that @mention it. Each channel thread is its own chat. A group chat has no threads, so each member who mentions Cotool there continues their own chat, which starts over on `new chat` or after 12 idle hours, as a direct chat does.

If Cotool is still working on your previous message in a chat, it asks you to send the new one again once it has replied.

## Approvals

When an agent action requires approval, Cotool can post the request to a Teams channel or group chat:

1. Create a Teams destination that posts to the channel, if you don't have one (**Configure Teams**, then pick the channel under **Post to**).
2. Open the agent and the action that needs approval.
3. Turn on **Require approval**.
4. Under **Microsoft Teams**, pick the destination.

The request shows the agent, the action and its arguments, with **Approve** and **Reject** buttons. A destination that posts to a workflow webhook gets a link to approve in Cotool instead. Only Cotool users who can run the agent can decide. Once someone decides, in Teams or in Cotool, the card shows the outcome and who made it.

Everyone in the channel can see each request and its arguments.

## Available tools

| Tool | What it does |
| - | - |
| `msft_teams_listConversations` | Lists the channels, group chats and direct chats the app is in |
| `msft_teams_searchChannels` | Searches those channels and group chats by team, channel or chat name |
| `msft_teams_getChannelDetails` | Gets a channel's or group chat's name, description, kind and link |
| `msft_teams_sendMessage` | Sends a message to a conversation. In a channel this starts a new post |
| `msft_teams_replyToThread` | Replies in a thread or chat, such as the one a person messaged Cotool from |
| `msft_teams_readChannelMessages` | Reads a channel's posts or a group chat's messages, newest first |
| `msft_teams_readThreadMessages` | Reads the replies under a channel post |
| `msft_teams_findUsers` | Searches a conversation's members by name, email or sign-in name |
| `msft_teams_getUsersByIds` | Gets members' names and emails by their Microsoft Entra user IDs |
| `msft_teams_downloadMessageFiles` | Downloads a message's pasted images into the agent's sandbox |
| `msft_teams_waitForUserResponse` | Asks a question with answer buttons and pauses the run until someone clicks one, or it times out |

Agents can only post to and read conversations the Cotool app is in for your organization.

### Reading messages and files

Reading uses the permissions the app is granted in each team and group chat it is added to. A team the app was added to before it had those permissions refuses the read; remove the app from the team and add it again.

* Direct chats with Cotool cannot be read.
* Images pasted into a channel or group chat message can be downloaded with `msft_teams_downloadMessageFiles`.
* Files attached to a channel message can be downloaded once an administrator has let Cotool read that team's files. See [Letting Cotool read channel files](#letting-cotool-read-channel-files).
* Files attached to a group chat message cannot be read, because Teams stores them in the sender's OneDrive. Send the file to Cotool in a direct chat instead.
* People are looked up among a conversation's members. For a channel, that is the members of its team.

### Letting Cotool read channel files

Each team's files live in a SharePoint site. Cotool can read none of them until a SharePoint administrator grants the Cotool app read access to a team's site. The grant covers every standard channel in that team. A private or shared channel has its own site and needs its own grant.

The administrator must be a member of the site. With [PnP PowerShell](https://pnp.github.io/powershell/):

```powershell theme={null}
Connect-PnPOnline -Url https://<your-tenant>.sharepoint.com/sites/<team> -Interactive
Grant-PnPAzureADAppSitePermission -AppId <Cotool app ID> -DisplayName "Cotool" `
    -Site https://<your-tenant>.sharepoint.com/sites/<team> -Permissions Read
```

The Cotool app ID is the application ID of **Cotool** under **Enterprise applications** in the Microsoft Entra admin center. When an agent is refused a file, its reply names the site to grant.

To take the access away, remove the grant with `Revoke-PnPAzureADAppSitePermission`.

### Sending Cotool files and images

| Where you send it | Pasted images | Attached files |
| - | - | - |
| Direct chat with Cotool | Yes | Yes |
| Channel or group chat (with an @mention) | Yes | No, Teams does not pass them to apps |

What Cotool receives is added to the chat as an upload, the same as a file attached in Cotool, so the agent can read it and work on it in its sandbox. Files over 30 MB are skipped, and the agent is told which ones it did not get.

### Images in Cotool's messages

Agents can attach up to four images to a message or reply, such as a chart or a screenshot. Teams shows them under the text. Cotool resizes each to fit Teams' limit of 1024 by 1024 pixels and 1 MB. Teams won't start a channel post with images, so in a new post they appear as the first reply in its thread.

### Mentioning people

Agents can @mention up to 20 people in a message, and Teams notifies them as it does for any mention. Only members of the conversation can be mentioned; for a channel, that's the members of its team.

Agents cannot attach other kinds of file in Teams yet.

### Asking a question and waiting

`msft_teams_waitForUserResponse` posts a card with one button per answer. Anyone in the conversation can answer; no Cotool account is needed. Approval requests are different: only Cotool users who can run the agent can decide those.

How long the agent waits follows the severity of the alert it is working on, as in Slack. When the time runs out the agent continues without an answer, and the card's buttons are removed. Unlike Slack, a Teams question takes no late answers.

## Not yet available in Teams

These work in Slack today and are not in the Teams app yet:

* Triggering a specific agent from a channel mention or an emoji reaction
* Changing an alert's status from a message
* Alert threads that mirror replies onto the alert
* Reacting to a message with an emoji
* Agents sending files other than images
* Reading files attached to group chat messages
* Setting a fixed wait time for questions on an agent


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.