Microsoft Teams
Send SAP documents and SharePoint links to Microsoft Teams channels via Microsoft Graph API.
Use Cases
- Finance team delivery of new SAP documents
- Document upload to Teams channel file tabs
- SharePoint link notifications for governed copies
Two delivery options, both via Microsoft Graph API: post the file (recommended — uploads to the channel's Files tab plus a link message) or post a SharePoint link (for files already delivered to SharePoint).
Choose authentication
| Option | When to use |
|---|---|
| Entra app-only | Unattended posting. Needs ChannelMessage.Send as an application permission — absent from some tenants. |
| Delegated user (alternative) | Posts as you. Needs ChannelMessage.Send as a delegated permission plus a one-off browser dance for a refresh token. No admin consent required by default. |
Graph API setup — app-only
- Azure Portal → Microsoft Entra ID → App registrations → New registration (e.g. "FileRelay Teams").
- API permissions → add Microsoft Graph application permissions:
ChannelMessage.Send— post channel messagesFiles.ReadWrite.All— upload to the channel Files tabChannel.ReadBasic.All— verify the channel exists during Test
- Grant admin consent (required).
- Certificates & secrets → new client secret. Note the client ID, tenant ID, and secret value.
- Find the team and channel IDs (see below).
- In FileRelay, add a Microsoft Teams destination: team + channel IDs, Entra credentials, and the delivery option.
Graph API setup — delegated user
Use this when the tenant's catalog has no app-only ChannelMessage.Send.
- Same app registration, but under API permissions → Delegated permissions add
ChannelMessage.Send,Files.ReadWrite, andoffline_access. User consent suffices (no admin consent required by default). - Create the client secret as above.
- Under Authentication, add a redirect URI for the dance: Add a platform → Web →
https://localhost/teams-dance(nothing runs there — you copy the code from the address bar). - Open this URL in a browser (replace the
{…}values) and sign in as the user who will own the posts:https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize?client_id={client_id}&response_type=code&scope=ChannelMessage.Send%20Files.ReadWrite%20offline_access&redirect_uri=https://localhost/teams-dance - After consent the browser lands on an unreachable localhost page — copy the
code=…value from its address bar. - Exchange the code for tokens:
curl -X POST "https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token" \ -d "client_id={client_id}&client_secret={client_secret}&grant_type=authorization_code" \ -d "code={code}&redirect_uri=https://localhost/teams-dance" \ -d "scope=ChannelMessage.Send%20Files.ReadWrite%20offline_access" - Copy the
refresh_tokenfrom the JSON response. It stays valid with use — FileRelay exchanges it on every send, so normal operation never lets it lapse. - In FileRelay, add a Microsoft Teams destination in delegated mode with tenant + client + secret + refresh token. File upload and link posting work identically, posted as the consenting user.
If the dance fails with
invalid_grant, the code expired (10-minute life) or the redirect URI mismatches the registered one — re-run from step 4.
REPLACE: Screenshot of the Graph API configuration in FileRelay
Test
Click Test — FileRelay mints a token and reads the channel back, proving the app, consent, and IDs are correct. Saving requires a passing test. (The test posts nothing; the first real delivery is the first proof a message lands.)
How each option delivers
Post the file — auths to Entra with client credentials, uploads the document to the channel's Files tab (backed by SharePoint), posts a channel message with a link to the file. Enrichment key-values are written to the file's library columns via metadata_mapping.
Post a SharePoint link — skips the upload and posts a channel message linking to file_url (the web URL from the SharePoint delivery). Enrichment key-values ride in the message text. Use when SharePoint holds the governed copy.
Message placeholders
message supports {fileName} and {fileUrl}, replaced per delivery.
Finding team + channel IDs
Graph Explorer:
GET https://graph.microsoft.com/v1.0/me/joinedTeams
GET https://graph.microsoft.com/v1.0/teams/{team_id}/channels
Teams app: right-click the channel name → Get link to channel. URL contains both:
https://teams.microsoft.com/l/channel/{channel_id}/...?groupId={team_id}&...
URL-decode channel_id from the path segment.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
| 401 on Test | Secret wrong/expired, or admin consent missing. |
| 404 on Test | Team or channel ID wrong — re-copy from the channel link (URL-decode the channel segment). |
| 403 on Test | App permissions insufficient — the Test message names the missing grant. |
| File lands but no message | Message post failed — the delivery row records it; retries re-post without duplicating the file (same path overwrite). |
Tips
- Private channels — the app must be explicitly authorised for the private channel.
- Rate limits — Graph API throttles per app per tenant. FileRelay handles 429s with backoff.
- Multiple channels — one destination per channel; attach as many to a routing rule as you need.
- Files tab storage — uploads go to the channel's SharePoint library, so files are searchable, versioned, and reachable from SharePoint too.
Configuration Fields
| Field | Type | Required | Description |
|---|---|---|---|
| team_id | string | Required | Teams team ID |
| channel_id | string | Required | Teams channel ID |
| include_file | boolean | Optional | Post the file (true) or a SharePoint link instead (false, requires file_url) |
| file_url | string | Optional | SharePoint file URL for link mode |
| metadata_mapping | object | Optional | Our-key → library-column map for file mode (link mode embeds values in text) |
| message | string | Optional | Custom message text (supports {fileName} and {fileUrl} placeholders) |
Credentials
| Field | Type | Required | Description |
|---|---|---|---|
| client_id | string | Optional | Azure AD App Client ID (required for Graph API mode) |
| client_secret | string | Optional | Azure AD Client Secret (required for Graph API mode) |
| tenant_id | string | Optional | Azure AD Tenant ID (required for Graph API mode) |
| refresh_token | string | Optional | Delegated-mode refresh token (omit for app-only auth) |
All credentials are encrypted at rest using envelope encryption.
Ready to set up Microsoft Teams?
Create a free account and add this connector in under 2 minutes.