> Discover all available pages from the documentation index: https://mastra.zisheng.pro/llms.txt # Microsoft Teams Microsoft Teams Channels 让 Mastra Agent 能够接收来自 Teams 的提及和对话事件。Mastra 负责 Agent 接线和 webhook 路由;Chat SDK Teams 适配器文档则介绍 Teams 应用设置、身份验证和权限。 ## 安装适配器 从 Chat SDK 安装 Teams 适配器: **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 }, }) ``` ## 适配器设置 按照 [Chat SDK Teams 适配器文档](https://chat-sdk.dev/adapters/official/teams)完成 Teams 专用设置,包括 Azure 机器人注册、Teams CLI 用法、身份验证选项和所需权限。 适配器从以下环境变量中读取 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 和适配器键生成 Teams webhook 路由: ```text /api/agents/teams-agent/channels/teams/webhook ``` 使用公开的 Mastra Server URL 作为基础 URL: ```text https://your-app.example.com/api/agents/teams-agent/channels/teams/webhook ``` 在 Teams 适配器文档要求填写机器人端点或 webhook URL 的任何位置使用此 URL。本地开发时,请通过隧道公开 Mastra 开发 Server,并使用隧道 URL 作为基础 URL。 ## 相关内容 - [Channels 概览](https://mastra.zisheng.pro/docs/capabilities/channels/overview) - [更多适配器](https://mastra.zisheng.pro/docs/capabilities/channels/other-adapters)