Microsoft Teams 集成
让你的智能体访问 Teams 数据、发送消息、创建会议并管理频道。借助 AI 驱动的自动化,你可以自动化团队沟通、安排会议、检索消息,并简化协作工作流。
在使用 Microsoft Teams 集成之前,请确保你已具备:
- 一个拥有有效订阅的 CrewAI AMP 账户
- 一个可访问 Teams 的 Microsoft 账户
- 通过 集成页面 连接了你的 Microsoft 账户
设置 Microsoft Teams 集成
Section titled “设置 Microsoft Teams 集成”1. 连接你的 Microsoft 账户
Section titled “1. 连接你的 Microsoft 账户”- 访问 CrewAI AMP Integrations
- 在 Authentication Integrations 部分找到 Microsoft Teams
- 点击 Connect 并完成 OAuth 流程
- 授予 Teams 访问所需权限
- 从 Integration Settings 复制你的 Enterprise Token
2. 安装所需包
Section titled “2. 安装所需包”uv add crewai-tools3. 环境变量设置
Section titled “3. 环境变量设置”export CREWAI_PLATFORM_INTEGRATION_TOKEN="your_enterprise_token"或者将其添加到你的 .env 文件中:
CREWAI_PLATFORM_INTEGRATION_TOKEN=your_enterprise_tokenmicrosoft_teams/get_teams
说明: 获取用户所属的所有团队。
参数:
- 不需要参数。
microsoft_teams/get_channels
说明: 获取某个特定团队中的频道。
参数:
team_id(string, required): 团队 ID。
microsoft_teams/send_message
说明: 向 Teams 频道发送消息。
参数:
team_id(string, required): 团队 ID。channel_id(string, required): 频道 ID。message(string, required): 消息内容。content_type(string, optional): 内容类型(html 或 text)。枚举:html,text。默认值为text。
microsoft_teams/get_messages
说明: 获取 Teams 频道中的消息。
参数:
team_id(string, required): 团队 ID。channel_id(string, required): 频道 ID。top(integer, optional): 要检索的消息数量(最大 50)。默认值为20。
microsoft_teams/create_meeting
说明: 创建 Teams 会议。
参数:
subject(string, required): 会议主题/标题。startDateTime(string, required): 会议开始时间(带时区的 ISO 8601 格式)。endDateTime(string, required): 会议结束时间(带时区的 ISO 8601 格式)。
microsoft_teams/search_online_meetings_by_join_url
说明: 通过加入网页 URL 搜索在线会议。
参数:
join_web_url(string, required): 要搜索的会议加入网页 URL。
microsoft_teams/search_online_meetings_by_meeting_id
说明: 通过外部会议 ID 搜索在线会议。
参数:
join_meeting_id(string, required): 参会者用于加入的会议 ID(数字代码)。这是会议邀请中显示的 joinMeetingId,不是 Graph API 的 meeting id。
microsoft_teams/get_meeting
说明: 获取某个特定在线会议的详细信息。
参数:
meeting_id(string, required): Graph API 会议 ID(一个很长的字母数字字符串)。可通过 create_meeting 或 search_online_meetings 操作获取。与数字型 joinMeetingId 不同。
microsoft_teams/get_team_members
说明: 获取某个特定团队的成员。
参数:
team_id(string, required): 团队的唯一标识符。通过 get_teams 操作获取。top(integer, optional): 每页最多检索的成员数。默认值为100。skip_token(string, optional): 来自上一个响应的分页令牌。当响应包含 @odata.nextLink 时,提取其中的 $skiptoken 参数值并将其传入这里,以获取下一页结果。
microsoft_teams/create_channel
说明: 在团队中创建一个新频道。
参数:
team_id(string, required): 团队的唯一标识符。通过 get_teams 操作获取。display_name(string, required): Teams 中显示的频道名称。必须在团队内唯一。最多 50 个字符。description(string, optional): 可选描述,用于说明频道用途。会显示在频道详情中。最多 1024 个字符。membership_type(string, optional): 频道可见性。枚举:standard,private。“standard” = 所有团队成员都可见,“private” = 仅特定添加的成员可见。默认值为standard。
microsoft_teams/get_message_replies
说明: 获取某个频道中指定消息的回复。
参数:
team_id(string, required): 团队的唯一标识符。通过 get_teams 操作获取。channel_id(string, required): 频道的唯一标识符。通过 get_channels 操作获取。message_id(string, required): 父消息的唯一标识符。通过 get_messages 操作获取。top(integer, optional): 每页最多检索的回复数。默认值为50。skip_token(string, optional): 来自上一个响应的分页令牌。当响应包含 @odata.nextLink 时,提取其中的 $skiptoken 参数值并将其传入这里,以获取下一页结果。
microsoft_teams/reply_to_message
说明: 回复 Teams 频道中的一条消息。
参数:
team_id(string, required): 团队的唯一标识符。通过 get_teams 操作获取。channel_id(string, required): 频道的唯一标识符。通过 get_channels 操作获取。message_id(string, required): 要回复的消息的唯一标识符。通过 get_messages 操作获取。message(string, required): 回复内容。对于 HTML,请包含格式化标签。对于文本,只能使用纯文本。content_type(string, optional): 内容格式。枚举:html,text。“text” 表示纯文本,“html” 表示带格式的富文本。默认值为text。
microsoft_teams/update_meeting
说明: 更新已有的在线会议。
参数:
meeting_id(string, required): 会议的唯一标识符。通过 create_meeting 或 search_online_meetings 操作获取。subject(string, optional): 新的会议标题。startDateTime(string, optional): 新的开始时间,采用带时区的 ISO 8601 格式。示例:2024-01-20T10:00:00-08:00。endDateTime(string, optional): 新的结束时间,采用带时区的 ISO 8601 格式。
microsoft_teams/delete_meeting
说明: 删除在线会议。
参数:
meeting_id(string, required): 要删除的会议的唯一标识符。通过 create_meeting 或 search_online_meetings 操作获取。
基础 Microsoft Teams 智能体设置
Section titled “基础 Microsoft Teams 智能体设置”from crewai import Agent, Task, Crew
# Create an agent with Microsoft Teams capabilitiesteams_agent = Agent( role="Teams Coordinator", goal="Manage Teams communication and meetings efficiently", backstory="An AI assistant specialized in Microsoft Teams operations and team collaboration.", apps=['microsoft_teams'] # All Teams actions will be available)
# Task to list teams and channelsexplore_teams_task = Task( description="List all teams I'm a member of and then get the channels for the first team.", agent=teams_agent, expected_output="List of teams and channels displayed.")
# Run the taskcrew = Crew( agents=[teams_agent], tasks=[explore_teams_task])
crew.kickoff()from crewai import Agent, Task, Crew
# Create an agent focused on messagingmessenger = Agent( role="Teams Messenger", goal="Send and retrieve messages in Teams channels", backstory="An AI assistant skilled in team communication and message management.", apps=['microsoft_teams/send_message', 'microsoft_teams/get_messages'])
# Task to send a message and retrieve recent messagesmessaging_task = Task( description="Send a message 'Hello team! This is an automated update from our AI assistant.' to the General channel of team 'your_team_id', then retrieve the last 10 messages from that channel.", agent=messenger, expected_output="Message sent successfully and recent messages retrieved.")
crew = Crew( agents=[messenger], tasks=[messaging_task])
crew.kickoff()from crewai import Agent, Task, Crew
# Create an agent for meeting managementmeeting_scheduler = Agent( role="Meeting Scheduler", goal="Create and manage Teams meetings", backstory="An AI assistant that handles meeting scheduling and organization.", apps=['microsoft_teams/create_meeting', 'microsoft_teams/search_online_meetings_by_join_url'])
# Task to create a meetingschedule_meeting_task = Task( description="Create a Teams meeting titled 'Weekly Team Sync' scheduled for tomorrow at 10:00 AM lasting for 1 hour (use proper ISO 8601 format with timezone).", agent=meeting_scheduler, expected_output="Teams meeting created successfully with meeting details.")
crew = Crew( agents=[meeting_scheduler], tasks=[schedule_meeting_task])
crew.kickoff()认证错误
- 确保你的 Microsoft 账户拥有 Teams 访问所需权限。
- 所需范围包括:
Team.ReadBasic.All,Channel.ReadBasic.All,ChannelMessage.Send,ChannelMessage.Read.All,OnlineMeetings.ReadWrite,OnlineMeetings.Read。 - 验证 OAuth 连接是否包含全部所需范围。
团队和频道访问
- 确保你是要访问的团队成员。
- 仔细检查团队 ID 和频道 ID 是否正确。
- 可以使用
get_teams和get_channels操作获取团队和频道 ID。
消息发送问题
- 确保
send_message提供了team_id、channel_id和message。 - 验证你是否有权限向指定频道发送消息。
- 根据消息格式选择合适的
content_type(text 或 html)。
会议创建
- 确保提供了
subject、startDateTime和endDateTime。 - datetime 字段请使用带时区的正确 ISO 8601 格式(例如:
2024-01-20T10:00:00-08:00)。 - 验证会议时间是否在未来。
消息检索限制
get_messages操作每次请求最多可检索 50 条消息。- 消息按时间倒序返回(最新的在前)。
会议搜索
- 对于
search_online_meetings_by_join_url,请确保加入 URL 完全匹配且格式正确。 - 该 URL 应为完整的 Teams 会议加入链接。
需要帮助?
联系我们的支持团队,获取 Microsoft Teams 集成设置或故障排查方面的帮助。