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 實例上註冊 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 bot 註冊、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 URLWebhook 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 文件要求提供 bot 端點或 webhook URL 時,請使用此 URL。進行本機開發時,請透過 tunnel 對外開放 Mastra 開發伺服器,並使用 tunnel URL 作為基礎 URL。