> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Teams

> Client-mode REST API connector for a curated Microsoft Teams slice: Graph channel and chat messages plus Workflows Incoming Webhook Adaptive Cards

Technical Preview

## Overview

A client-mode connector for a **curated messaging** slice of [Microsoft Graph Teams](https://learn.microsoft.com/en-us/graph/api/channel-post-messages) and [Workflows Incoming Webhooks](https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook):

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| POST teams/\{id}/channels/\{id}/messages | `POST /teams/{team-id}/channels/{channel-id}/messages` | **Host:** `https://graph.microsoft.com/v1.0` — Bearer Entra token |
| POST Adaptive Card to webhook URL | `POST {webhook_path}` | **Host:** operator Workflows / Power Automate origin — no Authorization |
| POST chats/\{id}/messages | `POST /chats/{chat-id}/messages` | **Host:** Graph v1.0 — Bearer Entra token |

Default `BASE_ADDRESS` is `https://graph.microsoft.com/v1.0`. Topics use `messaging/microsoft-teams/<object>/<verb>`.

> [!NOTE]
>
> Workflows Incoming Webhooks are **not** on `graph.microsoft.com`. When calling `Postwebhookadaptivecard`, set connector `BASE_ADDRESS` to the webhook origin (scheme + host + port) and put path + query in `webhook_path`. Auth for the webhook is embedded in the URL; do not send an Authorization header.

> [!NOTE]
>
> Prefer Hub secrets for Entra access tokens. Channel/chat send usually needs a **delegated** token (`ChannelMessage.Send`, `Chat.ReadWrite`). This template has not been verified against a live Teams tenant. Status remains blocked until an authenticated live smoke succeeds.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — Microsoft Teams (Graph + Workflows webhook)
# Auth Graph: Bearer {value.json.access_token}
# Auth Webhook: none (URL embeds signature)
# BASE_ADDRESS Graph: https://graph.microsoft.com/v1.0
# Webhook: set BASE_ADDRESS to webhook origin

DEFINE ROUTE MicrosoftTeamsRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://graph.microsoft.com/v1.0"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Postchannelmessage
        WITH SOURCE_TOPIC "messaging/microsoft-teams/channel/message"
        WITH DESTINATION_TOPIC "messaging/microsoft-teams/channel/message/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/teams/{value.json.team_id}/channels/{value.json.channel_id}/messages"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"
    ADD EVENT Postchatmessage
        WITH SOURCE_TOPIC "messaging/microsoft-teams/chat/message"
        WITH DESTINATION_TOPIC "messaging/microsoft-teams/chat/message/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/chats/{value.json.chat_id}/messages"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"
    ADD EVENT Postwebhookadaptivecard
        WITH SOURCE_TOPIC "messaging/microsoft-teams/webhook/adaptive-card"
        WITH DESTINATION_TOPIC "messaging/microsoft-teams/webhook/adaptive-card/response"
        WITH METHOD "POST"
        WITH ENDPOINT "{value.json.webhook_path}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
        WITH BODY "{payload}"
```

## Events

| Event | Method | Endpoint | Request topic | Response topic |
| - | - | - | - | - |
| Postchannelmessage | POST | `/teams/{team_id}/channels/{channel_id}/messages` | `messaging/microsoft-teams/channel/message` | `messaging/microsoft-teams/channel/message/response` |
| Postchatmessage | POST | `/chats/{chat_id}/messages` | `messaging/microsoft-teams/chat/message` | `messaging/microsoft-teams/chat/message/response` |
| Postwebhookadaptivecard | POST | `{webhook_path}` | `messaging/microsoft-teams/webhook/adaptive-card` | `messaging/microsoft-teams/webhook/adaptive-card/response` |

## Auth

**Microsoft Graph (channel / chat):**

1. Register an Entra ID app (or use an existing one) and obtain an access token for `https://graph.microsoft.com`.
2. Prefer **delegated** permissions: `ChannelMessage.Send`, `Chat.ReadWrite` / `ChatMessage.Send`.
3. Set connector `BASE_ADDRESS` to `https://graph.microsoft.com/v1.0`.
4. Pass `access_token` on the MQTT request payload so headers resolve: `Authorization: Bearer {value.json.access_token}`.
5. Store the token in Hub secrets / `GET SECRET "TEAMS_GRAPH_TOKEN"`. Never commit real credentials.
6. Successful send returns **HTTP 201**.

**Workflows Incoming Webhook (Adaptive Card):**

1. In Teams, create a Workflow from a webhook template (or Power Automate "When a Teams webhook request is received").
2. Copy the HTTP POST URL. Split into origin → `BASE_ADDRESS` and path+query → `webhook_path`.
3. POST an Adaptive Card wrapper (`type: message`, `attachments[].contentType: application/vnd.microsoft.card.adaptive`).
4. No Authorization header. Expect **HTTP 200/202** depending on the connector.

## Example payloads

**Channel message:**

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "access_token": "YOUR_ENTRA_ACCESS_TOKEN",
  "team_id": "TEAM_GUID",
  "channel_id": "CHANNEL_ID",
  "body": { "content": "Hello from Coreflux" }
}
```

**Chat message:**

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "access_token": "YOUR_ENTRA_ACCESS_TOKEN",
  "chat_id": "CHAT_ID",
  "body": { "content": "Operator ack" }
}
```

**Webhook Adaptive Card** (`BASE_ADDRESS` = webhook origin):

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "webhook_path": "/workflows/.../triggers/manual/paths/invoke?api-version=2016-06-01&sp=...&sv=1.0&sig=...",
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "contentUrl": null,
      "content": {
        "type": "AdaptiveCard",
        "version": "1.4",
        "body": [{ "type": "TextBlock", "text": "Coreflux alarm", "weight": "Bolder" }]
      }
    }
  ]
}
```

## Deploy notes

* Deploy **`MicrosoftTeamsRestApi.lot` only** (`-addRoute`). Do **not** deploy `hub-metadata.lot` as a connector — it exists for Hub / `-listTemplates` (`ADD METADATA` + `WITH IMAGE` base64).
* Hub category: **REST API Connectors**.
* Doc link: [https://docs.coreflux.org/latest/lot-language/routes/rest-api-apps/microsoft-teams](https://docs.coreflux.org/latest/lot-language/routes/rest-api-apps/microsoft-teams)

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.