enhancementgood first issueintegrationnew-featurenew-integration
Repository-Metriken
- Stars
- (1.930 Sterne)
- PR-Merge-Metriken
- (PR-Metriken ausstehend)
Beschreibung
Description
Add Microsoft Teams integration to sync team channels, messages, meetings, and collaboration activity into CORE via Microsoft Graph API.
Reference Implementations
Existing Integrations (use as templates)
integrations/slack/- Similar team messaging platformintegrations/github/- Similar event-driven systemintegrations/linear/- Project management integration
Required Files Structure
integrations/teams/
├── src/
│ ├── index.ts # Main entry, OAuth spec
│ ├── schedule.ts # Sync logic
│ ├── utils.ts # Microsoft Graph API utilities
│ ├── account-create.ts # OAuth setup
│ └── create-activity.ts # Activity formatting
├── package.json
├── tsup.config.ts
└── README.md
Microsoft Graph API (Teams) Integration
OAuth Setup
- Use OAuth 2.0 (Authorization Code Grant) via Microsoft Identity Platform
- Authorization URL:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize - Token URL:
https://login.microsoftonline.com/common/oauth2/v2.0/token - Required scopes:
Team.ReadBasic.All- Read teams the user is a member ofChannel.ReadBasic.All- Read channel names and descriptionsChannelMessage.Read.All- Read channel messagesChannelMessage.Send- Send messages to channelsChat.Read- Read user's chatsChat.ReadWrite- Read and send chat messagesChatMessage.Read- Read chat messagesOnlineMeetings.Read- Read online meeting detailsUser.Read- Read user profileoffline_access- Refresh token supportopenid- OpenID Connect sign-inGroup.Read.All- Read group info (teams are Microsoft 365 groups)
Base URL
https://graph.microsoft.com/v1.0- Beta endpoint:
https://graph.microsoft.com/beta
Key Endpoints
Teams
GET /me/joinedTeams- List teams the user has joinedGET /teams/{team-id}- Get team detailsGET /teams/{team-id}/members- List team membersGET /groups/{group-id}/team- Get team from group
Channels
GET /teams/{team-id}/channels- List channels in a teamGET /teams/{team-id}/channels/{channel-id}- Get channel detailsPOST /teams/{team-id}/channels- Create a channelPATCH /teams/{team-id}/channels/{channel-id}- Update a channelDELETE /teams/{team-id}/channels/{channel-id}- Delete a channelGET /teams/{team-id}/channels/{channel-id}/members- List channel members
Channel Messages
GET /teams/{team-id}/channels/{channel-id}/messages- List channel messagesGET /teams/{team-id}/channels/{channel-id}/messages/{message-id}- Get a messagePOST /teams/{team-id}/channels/{channel-id}/messages- Send a message to channelGET /teams/{team-id}/channels/{channel-id}/messages/{message-id}/replies- List repliesPOST /teams/{team-id}/channels/{channel-id}/messages/{message-id}/replies- Reply to a messageGET /teams/{team-id}/channels/{channel-id}/messages/delta- Delta query for messages
Chats (1:1 and Group)
GET /me/chats- List user's chatsGET /chats/{chat-id}- Get a chatGET /chats/{chat-id}/messages- List chat messagesPOST /chats/{chat-id}/messages- Send a chat messageGET /chats/{chat-id}/members- List chat members
Online Meetings
GET /me/onlineMeetings- List online meetingsPOST /me/onlineMeetings- Create an online meetingGET /me/onlineMeetings/{meeting-id}- Get meeting detailsGET /me/onlineMeetings/{meeting-id}/attendanceReports- Get attendance reports
Subscriptions (Webhooks)
POST /subscriptions- Create change notification subscriptionGET /subscriptions- List active subscriptionsPATCH /subscriptions/{id}- Renew a subscriptionDELETE /subscriptions/{id}- Delete a subscription
Events to Track
-
Channel Message Events
- Message posted in channel
- Message replied to
- Message edited
- Message deleted
- Mention in channel message
-
Chat Events
- Chat message received
- Chat message sent
- New chat started
- Member added/removed from chat
-
Team/Channel Events
- Channel created
- Channel updated/renamed
- Channel deleted
- Member added/removed from team
- Team settings updated
-
Meeting Events
- Meeting created
- Meeting started/ended
- Participant joined/left
- Meeting recording available
Implementation Tasks
- Set up basic integration structure following
integrations/github/src/index.tspattern - Implement OAuth 2.0 flow in
account-create.tswith Microsoft Identity Platform - Create Microsoft Graph API utilities in
utils.ts(can share with Outlook integration) - Implement sync logic in
schedule.tsfor channels, messages, and meetings - Set up Graph API subscriptions (webhooks) for real-time message notifications
- Convert Teams events to CORE activity format
- Handle delta queries for efficient incremental message sync
- Implement pagination with
@odata.nextLink - Add error handling and rate limiting
- Create integration documentation
- Add to
integrations/README.md
Technical Notes
- Microsoft Graph API v1.0 is the stable endpoint; beta has newer features but may change
- Teams are built on Microsoft 365 Groups - a team ID is also a group ID
- Sending messages to channels requires delegated permissions (not application); app-only tokens cannot post messages in real-time
- Channel message subscriptions require
ChannelMessage.Read.Allscope - Delta queries available for channel messages (
/messages/delta) for incremental sync - Subscriptions (webhooks) must be renewed before expiry (max lifetime varies by resource)
- Access tokens expire after ~1 hour; refresh tokens last 90 days with continuous use
- Rate limiting: Varies by endpoint; typically 30 requests/second for messaging
- Consider sharing Graph API utilities with Microsoft Outlook integration
- Rich message formatting uses HTML or Adaptive Cards
- Attachments in messages require additional handling (hosted content)
Resources
- Microsoft Teams API Overview
- List Channel Messages
- Microsoft Graph API Overview
- Microsoft Graph Auth Overview
- Graph API Permissions Reference
- Teams Scopes Guide
- Change Notifications / Subscriptions
- Graph API Teams Integration (nBold)
Labels
enhancement, integration, new-feature