docs/en/enterprise/integrations/microsoft_teams.mdx
Enable your agents to access Teams data, send messages, create meetings, and manage channels. Automate team communication, schedule meetings, retrieve messages, and streamline your collaboration workflows with AI-powered automation.
Before using the Microsoft Teams integration, ensure you have:
uv add crewai-tools
export CREWAI_PLATFORM_INTEGRATION_TOKEN="your_enterprise_token"
Or add it to your .env file:
CREWAI_PLATFORM_INTEGRATION_TOKEN=your_enterprise_token
**Parameters:**
- No parameters required.
**Parameters:**
- `team_id` (string, required): The ID of the team.
**Parameters:**
- `team_id` (string, required): The ID of the team.
- `channel_id` (string, required): The ID of the channel.
- `message` (string, required): The message content.
- `content_type` (string, optional): Content type (html or text). Enum: `html`, `text`. Default is `text`.
**Parameters:**
- `team_id` (string, required): The ID of the team.
- `channel_id` (string, required): The ID of the channel.
- `top` (integer, optional): Number of messages to retrieve (max 50). Default is `20`.
**Parameters:**
- `subject` (string, required): Meeting subject/title.
- `startDateTime` (string, required): Meeting start time (ISO 8601 format with timezone).
- `endDateTime` (string, required): Meeting end time (ISO 8601 format with timezone).
**Parameters:**
- `join_web_url` (string, required): The join web URL of the meeting to search for.
**Parameters:**
- `join_meeting_id` (string, required): The meeting ID (numeric code) that attendees use to join. This is the joinMeetingId shown in meeting invitations, not the Graph API meeting id.
**Parameters:**
- `meeting_id` (string, required): The Graph API meeting ID (a long alphanumeric string). Obtain from create_meeting or search_online_meetings actions. Different from the numeric joinMeetingId.
**Parameters:**
- `team_id` (string, required): The unique identifier of the team. Obtain from get_teams action.
- `top` (integer, optional): Maximum number of members to retrieve per page (1-999). Default is `100`.
- `skip_token` (string, optional): Pagination token from a previous response. When the response includes @odata.nextLink, extract the $skiptoken parameter value and pass it here to get the next page of results.
**Parameters:**
- `team_id` (string, required): The unique identifier of the team. Obtain from get_teams action.
- `display_name` (string, required): Name of the channel as displayed in Teams. Must be unique within the team. Max 50 characters.
- `description` (string, optional): Optional description explaining the channel's purpose. Visible in channel details. Max 1024 characters.
- `membership_type` (string, optional): Channel visibility. Enum: `standard`, `private`. "standard" = visible to all team members, "private" = visible only to specifically added members. Default is `standard`.
**Parameters:**
- `team_id` (string, required): The unique identifier of the team. Obtain from get_teams action.
- `channel_id` (string, required): The unique identifier of the channel. Obtain from get_channels action.
- `message_id` (string, required): The unique identifier of the parent message. Obtain from get_messages action.
- `top` (integer, optional): Maximum number of replies to retrieve per page (1-50). Default is `50`.
- `skip_token` (string, optional): Pagination token from a previous response. When the response includes @odata.nextLink, extract the $skiptoken parameter value and pass it here to get the next page of results.
**Parameters:**
- `team_id` (string, required): The unique identifier of the team. Obtain from get_teams action.
- `channel_id` (string, required): The unique identifier of the channel. Obtain from get_channels action.
- `message_id` (string, required): The unique identifier of the message to reply to. Obtain from get_messages action.
- `message` (string, required): The reply content. For HTML, include formatting tags. For text, plain text only.
- `content_type` (string, optional): Content format. Enum: `html`, `text`. "text" for plain text, "html" for rich text with formatting. Default is `text`.
**Parameters:**
- `meeting_id` (string, required): The unique identifier of the meeting. Obtain from create_meeting or search_online_meetings actions.
- `subject` (string, optional): New meeting title.
- `startDateTime` (string, optional): New start time in ISO 8601 format with timezone. Example: "2024-01-20T10:00:00-08:00".
- `endDateTime` (string, optional): New end time in ISO 8601 format with timezone.
**Parameters:**
- `meeting_id` (string, required): The unique identifier of the meeting to delete. Obtain from create_meeting or search_online_meetings actions.
from crewai import Agent, Task, Crew
# Create an agent with Microsoft Teams capabilities
teams_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 channels
explore_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 task
crew = Crew(
agents=[teams_agent],
tasks=[explore_teams_task]
)
crew.kickoff()
from crewai import Agent, Task, Crew
# Create an agent focused on messaging
messenger = 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 messages
messaging_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 management
meeting_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 meeting
schedule_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()
Authentication Errors
Team.ReadBasic.All, Channel.ReadBasic.All, ChannelMessage.Send, ChannelMessage.Read.All, OnlineMeetings.ReadWrite, OnlineMeetings.Read.Team and Channel Access
get_teams and get_channels actions.Message Sending Issues
team_id, channel_id, and message are provided for send_message.content_type (text or html) based on your message format.Meeting Creation
subject, startDateTime, and endDateTime are provided.Message Retrieval Limitations
get_messages action can retrieve a maximum of 50 messages per request.Meeting Search
search_online_meetings_by_join_url, ensure the join URL is exact and properly formatted.