Skip to main content

Microsoft Teams Bot

The Microsoft Teams Bot integration lets users hold a bidirectional conversation with OctoMesh directly from a Microsoft Teams chat: they can send messages (questions) and upload files (for example invoices), and receive answers back in the same conversation.

It is built on the Azure Bot Service and two mesh-adapter pipeline nodes:

NodeKindPurpose
FromTeamsBot@1TriggerHosts the Bot Framework messaging endpoint (POST /{tenant}/teamsBot), authenticates the request, downloads any file attachments and starts the pipeline for the incoming message.
TeamsBotReply@1LoadSends a reply back into the originating conversation through the Bot Framework REST API.

Unlike the polling-based FromMicrosoftGraph@1 trigger (which only reads a Teams channel), the bot is real-time and two-way: it supports 1:1 chats, file uploads and threaded replies.

Architecture

  1. The user writes to the bot in Teams.
  2. Azure Bot Service relays the activity to the mesh adapter's messaging endpoint. For local development the endpoint is exposed through a dev tunnel (see Setup); in production it is a public HTTPS URL of the adapter.
  3. FromTeamsBot@1 normalises the activity — including downloaded file attachments — into the same $.Emails[] / AttachmentData shape produced by the e-mail and Graph triggers, so the downstream pipeline is channel-agnostic. Conversation routing metadata (serviceUrl, conversationId, sender) is placed at $.Conversation.
  4. Your pipeline does whatever it needs (query data, run an AI prompt, store an uploaded file …).
  5. TeamsBotReply@1 posts the answer back into the conversation.

Unified message shape

FromTeamsBot@1 emits the same structure as FromEmail@1 / FromMicrosoftGraph@1:

$.Emails[0].Body — the message text
$.Emails[0].From — sender display name
$.Emails[0].Attachments[0].Data — base64 file content (PDF, image, …)
$.Emails[0].Attachments[0].ContentType
$.Conversation.ServiceUrl — where TeamsBotReply@1 sends the answer
$.Conversation.ConversationId
$.Conversation.ActivityId — for threaded replies

This means a single pipeline can serve e-mail and Teams with only the trigger and the reply node differing per channel.

Credentials

Both nodes read their credentials from a MicrosoftGraphConfiguration entity resolved by name through a Uses association on the pipeline. The Azure AD App Registration's ClientId / ClientSecret double as the bot's App ID / secret, and AzureTenantId selects the token authority (required for a single-tenant bot — see below) and is also used to download channel (SharePoint) file attachments via Microsoft Graph.

Single-tenant vs. multi-tenant bot

Many Azure AD tenants now block the creation of multi-tenant app registrations, so the Azure Bot resource only offers Single Tenant (or Managed Identity, which has no client secret and cannot be used here). A single-tenant bot is fully supported:

  • TeamsBotReply@1 requests its Bot Framework token from the tenant authority https://login.microsoftonline.com/{AzureTenantId}/oauth2/v2.0/token when AzureTenantId is set, and from the botframework.com authority (multi-tenant) when it is blank.
  • Therefore AzureTenantId is mandatory for a single-tenant bot.

Continue with the step-by-step Setup.