> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-HK/llms.txt # Microsoft Teams Microsoft Teams 頻道讓 Mastra Agent 接收來自 Teams 的提及通知和對話事件。Mastra 會處理 Agent 連接和 webhook 路由;Chat SDK Teams adapter 文件則涵蓋 Teams 應用程式設定、身份驗證和權限。 ## 安裝 adapter 從 Chat SDK 安裝 Teams adapter: **npm**: ```bash npm install @chat-adapter/teams ``` **pnpm**: ```bash pnpm add @chat-adapter/teams ``` **Yarn**: ```bash yarn add @chat-adapter/teams ``` **Bun**: ```bash bun add @chat-adapter/teams ``` ## Agent 設定 將 `createTeamsAdapter()` 加至 Agent 的 `channels.adapters` 物件: ```typescript 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: ```typescript import { Mastra } from '@mastra/core' import { teamsAgent } from './agents/teams-agent' export const mastra = new Mastra({ agents: { teamsAgent }, }) ``` ## Adapter 設定 請按照 [Chat SDK Teams adapter 文件](https://chat-sdk.dev/adapters/official/teams)完成 Teams 專用設定,包括 Azure bot 註冊、Teams CLI 使用方式、身份驗證選項和必要權限。 Adapter 會從環境變數讀取 Teams 憑證,例如: ```bash 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 Mastra 會根據 Agent ID 和 adapter key 產生 Teams webhook 路由: ```text /api/agents/teams-agent/channels/teams/webhook ``` 使用公開的 Mastra 伺服器 URL 作為基礎 URL: ```text https://your-app.example.com/api/agents/teams-agent/channels/teams/webhook ``` 當 Teams adapter 文件要求提供 bot 端點或 webhook URL 時,請使用此 URL。進行本機開發時,請透過 tunnel 對外開放 Mastra 開發伺服器,並使用 tunnel URL 作為基礎 URL。 ## 相關內容 - [頻道概覽](https://mastra.zisheng.pro/zh-HK/docs/capabilities/channels/overview) - [更多選項](https://mastra.zisheng.pro/zh-HK/docs/capabilities/channels/other-adapters)