メインコンテンツへ移動

Microsoft Teams

Microsoft Teams channel を使用すると、Mastra Agent は Teams のメンションと会話イベントを受信できます。Mastra は Agent の接続と Webhook ルートを処理します。Teams アプリの設定、認証、権限については、Chat SDK の Teams アダプターのドキュメントを参照してください。

アダプターのインストール
アダプターのインストールへの直接リンク

Chat SDK から Teams アダプターをインストールします。

npm install @chat-adapter/teams

Agent の設定
Agent の設定への直接リンク

Agent の channels.adapters オブジェクトに createTeamsAdapter() を追加します。

src/mastra/agents/teams-agent.ts
import { Agent } from '@mastra/core/agent'
import { createTeamsAdapter } from '@chat-adapter/teams'

export const teamsAgent = new Agent({
id: 'teams-agent',
name: 'Teams Agent',
instructions: 'Answer questions and help with tasks in Microsoft Teams.',
model: 'openai/gpt-5.6-sol',
channels: {
adapters: {
teams: createTeamsAdapter({
appType: 'SingleTenant',
}),
},
},
})

Mastra インスタンスに Agent を登録します。

src/mastra/index.ts
import { Mastra } from '@mastra/core'
import { teamsAgent } from './agents/teams-agent'

export const mastra = new Mastra({
agents: { teamsAgent },
})

アダプターの設定
アダプターの設定への直接リンク

Azure Bot の登録、Teams CLI の使用方法、認証オプション、必要な権限など、Teams 固有の設定については、Chat SDK Teams アダプターのドキュメントに従ってください。

アダプターは、次のような環境変数から Teams の認証情報を読み取ります。

.env
TEAMS_APP_ID=your-azure-bot-app-id
TEAMS_APP_PASSWORD=your-azure-bot-app-password
TEAMS_APP_TENANT_ID=your-azure-tenant-id

Webhook URL
Webhook URLへの直接リンク

Mastra は、Agent ID とアダプターキーから Teams の Webhook ルートを生成します。

/api/agents/teams-agent/channels/teams/webhook

公開されている Mastra サーバーの URL をベース URL として使用します。

https://your-app.example.com/api/agents/teams-agent/channels/teams/webhook

Teams アダプターのドキュメントで Bot エンドポイントまたは Webhook URL が求められる箇所には、この URL を使用します。ローカル開発では、トンネルで Mastra 開発サーバーを公開し、そのトンネル URL をベース URL として使用してください。