Channels
Msteams
OpenClaw Microsoft Teams channel plugin (User Account via Graph API)
Install
npm install
openclaw
Configuration Example
{
"channels": {
"msteams-user": {
"enabled": true,
"clientId": "your-azure-app-client-id",
"tenantId": "your-azure-tenant-id",
"userId": "user-object-id",
"webhook": {
"port": 3978,
"url": "https://your-public-domain.com",
"clientState": "your-shared-secret"
},
"dmPolicy": "allowlist",
"allowFrom": ["[email protected]"]
}
}
}
README
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/logo.svg">
<source media="(prefers-color-scheme: light)" srcset="assets/logo.svg">
<img alt="openclaw-msteams" src="assets/logo.svg" width="100%">
</picture>
</p>
Microsoft Teams channel plugin for [OpenClaw](https://openclaw.ai) that sends and receives messages **as a real M365 user account** โ not a bot.
**User identity** | **Delegated auth** | **Graph API** | **Webhook subscriptions** | **Open source**



---
## Features
- **Real user identity** โ Messages appear as your M365 user, not a bot
- **Delegated auth** โ Device-code flow with persistent token cache (~90 day refresh)
- **Inbound webhooks** โ Receives Teams notifications via Graph API subscriptions
- **Auto-renewal** โ Subscriptions auto-renew every 50 minutes (60-min expiry)
- **Session routing** โ `person:<email>` for 1:1 chats, `group:<chatId>` for groups
- **DM policies** โ Supports `open`, `allowlist`, and `pairing` modes
- **Markdown chunking** โ Long messages split at 4000-char boundaries
## Quick Start
### Install
```bash
openclaw plugins install @knowall-ai/openclaw-msteams
```
### Configure
Add to your `openclaw.json`:
```json
{
"channels": {
"msteams-user": {
"enabled": true,
"clientId": "your-azure-app-client-id",
"tenantId": "your-azure-tenant-id",
"userId": "user-object-id",
"webhook": {
"port": 3978,
"url": "https://your-public-domain.com",
"clientState": "your-shared-secret"
},
"dmPolicy": "allowlist",
"allowFrom": ["[email protected]"]
}
}
}
```
### Authenticate
```bash
openclaw channels login msteams-user
```
Visit the URL shown, enter the code, sign in with the M365 account. Done โ tokens auto-renew for ~90 days.
### Verify
```bash
openclaw channels status msteams-user
# Microsoft Teams (User) default: enabled, configured, running, works
```
## How It Works
```
MS Graph Webhooks โโโถ Plugin Monitor (:3978) โโโถ OpenClaw Gateway
โ โ
โ validates clientState โ processes message
โ enriches sender info โ routes to session
โ fetches conversation โ
โผ โผ
/hooks/wake Agent replies via
Graph API outbound
โ
โผ
Teams Chat
(as real M365 user)
```
## Prerequisites
| Requirement | Details |
|-------------|---------|
| OpenClaw | Running instance |
| Node.js | 18+ |
| Azure AD App | With delegated Graph API permissions |
| Public HTTPS | For Graph webhook notifications |
### Required Azure AD Permissions (Delegated)
- `Chat.ReadWrite` โ Read and send chat messages
- `ChatMessage.Send` โ Send messages in chats
- `ChannelMessage.Send` โ Send messages in channels
- `User.Read` โ Read authenticated user profile
- `Chat.Read` โ Read chat metadata
- `User.ReadBasic.All` โ Read basic profile of other users
## Project Structure
```
โโโ index.ts # Plugin entry point
โโโ openclaw.plugin.json # Plugin manifest
โโโ package.json # Package config
โโโ src/
โ โโโ auth.ts # MSAL delegated auth (device-code flow)
โ โโโ channel.ts # ChannelPlugin definition (all adapters)
โ โโโ inbound.ts # Notification processing + session routing
โ โโโ monitor.ts # Express webhook server
โ โโโ outbound.ts # ChannelOutboundAdapter
โ โโโ runtime.ts # Plugin runtime getter/setter
โ โโโ send.ts # Graph API message sending
โ โโโ subscriptions.ts # Graph webhook subscription lifecycle
โ โโโ token.ts # Credential resolution from config
โ โโโ types.ts # Shared TypeScript types
โโโ docs/
โโโ SOLUTION_DESIGN.adoc # Architecture and design
โโโ DEPLOYMENT.adoc # Installation and configuration
โโโ TESTING.adoc # Testing guide
โโโ TROUBLESHOOTING.adoc # Common issues and fixes
โโโ generate-docs.sh # PDF generator script
โโโ themes/
โโโ knowall-theme.yml # PDF theme
```
## Documentation
| Document | Description |
|----------|-------------|
| [Solution Design](docs/SOLUTION_DESIGN.adoc) | Architecture, data flow, design decisions |
| [Deployment](docs/DEPLOYMENT.adoc) | Installation, configuration, reverse proxy |
| [Testing](docs/TESTING.adoc) | Manual testing checklist, verification |
| [Troubleshooting](docs/TROUBLESHOOTING.adoc) | Common issues and their fixes |
## vs. Official `@openclaw/msteams`
| | This Plugin | Official Plugin |
|--|-------------|-----------------|
| **Identity** | Real M365 user | Bot identity |
| **Auth** | Delegated (device-code) | Bot Framework (app credentials) |
| **API** | Microsoft Graph | Bot Framework SDK |
| **Messages** | Appear as the user | Appear as a bot |
| **Setup** | Azure AD app + login | Bot registration + channels |
## Development
```bash
git clone https://github.com/knowall-ai/openclaw-msteams.git
cd openclaw-msteams
npm install
openclaw plugins install --link ./index.ts
```
## License
MIT
---
Built by [KnowAll AI](https://knowall.ai)
channels
Comments
Sign in to leave a comment