Microsoft Teams
Microsoft Teams 頻道可讓 Mastra Agent 接收來自 Teams 的提及與對話事件。Mastra 會處理 Agent 串接與 webhook 路由;Chat SDK Teams adapter 文件則涵蓋 Teams 應用程式設定、驗證與權限。
安裝 adapter「安裝 adapter」的直接連結
從 Chat SDK 安裝 Teams adapter:
- npm
- pnpm
- Yarn
- Bun
npm install @chat-adapter/teams
pnpm add @chat-adapter/teams
yarn add @chat-adapter/teams
bun add @chat-adapter/teams
Agent 設定「Agent 設定」的直接連結
將 createTeamsAdapter() 加入 Agent 的 channels.adapters 物件:
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 instance 上註冊 Agent:
src/mastra/index.ts
import { Mastra } from '@mastra/core'
import { teamsAgent } from './agents/teams-agent'
export const mastra = new Mastra({
agents: { teamsAgent },
})
Adapter 設定「Adapter 設定」的直接連結
請依照 Chat SDK Teams adapter 文件完成 Teams 專屬設定,包括 Azure 機器人註冊、Teams CLI 用法、驗證選項與必要權限。
Adapter 會從下列環境變數讀取 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 與 adapter key 產生 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 adapter 文件要求填入機器人端點或 webhook URL 時,請使用此 URL。本機開發時,請透過 tunnel 公開 Mastra 開發伺服器,並使用 tunnel URL 作為基底 URL。