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

# Teams

> Chat with Crew from Microsoft Teams. DM-only, self-hosted, with deny-by-default email allowlist and Bot Framework JWT validation.

Kiro Crew can run as a Microsoft Teams bot. DM your agent from Teams and get a typing indicator while it works, then the final reply in one message.

**⚠️ Warning:** Unlike the other channels (which connect outbound), Teams uses the Bot Framework push model — it requires a **public HTTPS URL** that reaches your gateway. Set up a reverse proxy, dev tunnel, or host on a public VM.

## How it works

The Microsoft Bot Framework **pushes** activities to an endpoint you host. Crew:

1. Registers an inbound route: `POST /api/messaging/teams`
2. Validates every request's `Authorization: Bearer <jwt>` against Bot Framework signing keys before processing
3. Fast-acks with `200`, runs the agent turn in the background, then sends the reply via the Bot Connector REST API

## Prerequisites

- A public HTTPS URL reaching your gateway (reverse proxy, dev tunnel, or public VM)
- The Teams extra installed: `pip install "kirocrew[teams]"`
- An Azure Bot registration with a Microsoft App ID and secret

## Setup

### From the dashboard (recommended)

1. Register an Azure Bot in the [Azure Portal](https://portal.azure.com) — create an Azure Bot resource, note the App ID, create a client secret, add the Microsoft Teams channel, and set the messaging endpoint to `https://<your-host>/api/messaging/teams`
2. Open **Settings → Messaging Channels → Teams** in the dashboard
3. Paste the **App ID**, **App Password** (client secret), and **Tenant ID** (or leave blank for multi-tenant)
4. Add your Azure AD email or object ID to the **Allowed emails** list
5. Click **Save** — the status badge turns green when the credentials validate

Then side-load a Teams app package (Developer Portal → new app → Bot with your App ID, scope Personal) and DM the bot.

### From the CLI

In `~/.kiro/crew/.env`:

```
MICROSOFT_APP_ID=<your app id>
MICROSOFT_APP_PASSWORD=<your client secret>
MICROSOFT_APP_TENANT_ID=<tenant id or leave unset>
```

In `~/.kiro/crew/config.json`:

```json
{
  "teams": {
    "enabled": true,
    "allowed_emails": ["you@yourcompany.com"]
  }
}
```

Install the Teams extra: `pip install "kirocrew[teams]"`

Then: `kirocrew restart`

## Commands

| Command | Effect |
|---|---|
| `/new` | Fresh conversation |
| `/compact` | Compress context |
| `/sessions` | Continue a recent or matching dashboard session in this conversation (owner only) |
| `/steer <message>` | Fold this message into the running turn |
| `/queue <message>` | Hold this message until the current turn finishes |
| `/help` | List commands |

## Messages that arrive mid-turn

Run `/sessions` to bind a Teams conversation to one of your dashboard sessions. It works only when `teams.allowed_emails` holds exactly one identity, so there is one clear owner; with a shared allowlist, the listing is refused to protect your dashboard transcripts. When a text message arrives while that session is already mid-turn, Kiro Crew keeps it rather than dropping it. It either steers the message into the running turn or queues it to run when the turn finishes. The conversation reports which happened: a steering reply says your message was folded into the running turn; a queued reply says it runs when the current turn finishes.

`messaging.queue_mode` in `config.json` sets the default: `steer` (the default) folds the message into the running reply; `queue` holds it for after the turn. A `/steer` or `/queue` prefix overrides the mode for that one message. A message with attachments is neither steered nor queued into the bound session; the reply asks you to send it again once the turn finishes. When no dashboard turn is in progress, the message runs as a fresh turn in the bound session.

## Security

- Webhook is **exempt from dashboard cookie gate** — performs its own Bot Framework JWT validation
- Authorization is **deny-by-default** on both the email allowlist and conversation scope (personal only)
- All denials recorded in the security event log
- App Password is marked sensitive and never logged

## Limitations

- 1:1 personal chat only — no team channels, group chats, or @mention handling
- No Adaptive Cards / tappable buttons (options delivered as plain text)
- No token-by-token streaming — typing indicator shown, final answer delivered in one message (chunked if long)

## Configuration

| Key | Default | Purpose |
|---|---|---|
| `teams.enabled` | `false` | Turns the channel on |
| `teams.allowed_emails` | `[]` | UPNs/emails/object IDs allowed (empty = nobody) |
| `teams.soft_threshold_pct` | `80` | Context % where bot suggests `/compact` |
| `teams.hard_threshold_pct` | `95` | Force-compact threshold |
| `messaging.queue_mode` | `steer` | How a message that arrives mid-turn is handled: `steer` folds it into the running reply, `queue` runs it after the turn (a shared messaging setting, not Teams-only) |

## Troubleshooting

| Problem | Fix |
|---|---|
| 401 on inbound requests | App ID or secret is wrong; check Azure Bot registration |
| Bot doesn't respond | Confirm `allowed_emails` includes your UPN or object ID |
| `kirocrew[teams]` not installed | Install with `pip install "kirocrew[teams]"` |
| No green badge in Settings | Outbound credential validation failed — check App ID/Password |
