# Microsoft Teams

> Put your agent inside your company's Microsoft Teams with your own Azure bot, no app store. It connects in 10 minutes and your admin installs it with a .zip.

URL: https://www.ghosty.studio/en/docs/channels/microsoft-teams

Your agent can live inside your company's **Microsoft Teams**: people message it directly or mention it in a channel, and it answers with what it knows and the tools you gave it. It doesn't go through the Teams app store: the bot is **yours**, registered in your company's Azure, and gs only answers through it.

Not to be confused with [Ghosty Teams](/en/docs/channels/teams), Ghosty's own team chat.

## What you need

- Access to your company's **Azure portal** (the same tenant as your Microsoft 365) with permission to create resources and register apps.
- Your **Teams admin** must allow custom app uploads (Teams admin center → Apps → Setup policies).
- The Azure Bot free plan (F0) is enough: the Teams channel doesn't charge per message.

## Connect it

1. In Azure, **create an Azure Bot**. App type: **Single Tenant**. Plan: **F0**.
2. In the bot, **Channels → Microsoft Teams** and save.
3. In **Configuration**, copy the **Microsoft App ID** and **App Tenant ID**. Under “Manage password” create a **client secret** and copy it.
4. In Ghosty, open the agent → **Channels → Microsoft Teams** and paste the three values. Ghosty tests them with Microsoft before saving; the secret is stored encrypted.
5. Copy the **messaging endpoint** Ghosty gives you (`https://www.ghosty.studio/api/mteams/messages/…`) and paste it in your Azure Bot → Configuration.
6. Before uploading anything you can try it: in your Azure Bot, **Test in Web Chat** already answers with your agent.
7. Click **Download the Teams .zip** and hand it to your admin: Teams admin center → **Manage apps → Upload new app**. Within a few hours it shows up under “Built for your org”.

If the bot doesn't answer, the agent page (and `ghosty channels mteams ls <agent>`; in `--json`, `lastError`) shows the last problem: for example “el token no es para este bot” means the messaging endpoint was pasted into a different Azure Bot.

## How it answers

- **Direct chat**: each person has their own conversation with the agent.
- **Channel or group chat**: the agent answers in the same thread when mentioned (`@name`), and each thread is its own conversation. If your message mentions someone else, the agent sees their name.
- When installed in a chat or team it says hello once and explains how to talk to it.
- It reads pasted images and, in direct chat, attached files (files in a channel live in SharePoint and it can't read them yet). Files it generates (PDF, Excel) arrive as a download link.
- Long answers arrive as several messages; while it thinks you see “typing…”.
- If you ask for a follow-up or a reminder (“check it tomorrow at 9”), the agent schedules itself and writes to you in the same chat or thread when it’s due.
- `/clear` starts the conversation over.

By default the channel is a **team** channel: whoever writes in your Teams is your people, so the agent can use admin tools. If you use it to serve outside people, switch the channel role to “customer” on the agent page.

## From the terminal and the API

```bash
ghosty channels mteams connect <agent> --app-id <guid> --tenant <guid> --name "Sofi"   # secret in GHOSTY_MTEAMS_SECRET
ghosty channels mteams ls <agent>                      # bots, endpoint, last message and last problem
ghosty channels mteams zip <agent> <bot> --out sofi-teams.zip
ghosty channels mteams off|on|rm <agent> <bot>
```

The API is `GET|POST|PATCH|DELETE /api/v2/agents/{id}/mteams` and `GET /api/v2/agents/{id}/mteams/{botId}/zip` (see the [API reference](/en/docs/api/reference)). Agent owner only.
