Skip to main content

Installation

Environment Variables

Register your bot at Azure Bot Service.

Configuration Options

Setup

For apps available to any organization:

Webhook Handler

Features

Supported Events

  • Message - Regular messages in channels/chats
  • MessageReaction - Emoji reactions added/removed
  • Invoke (Adaptive Card actions) - Button clicks
  • Action.Submit - Form submissions from Adaptive Cards

Message Types

The adapter handles:
  • Channel messages - Public/private channel posts
  • 1:1 chats - Direct messages with users
  • Group chats - Multi-user conversations
  • Thread replies - Replies in message threads

Adaptive Cards

Teams uses Adaptive Cards for rich UI:
Cards are automatically converted to Adaptive Card format. Text messages support basic markdown.

Reactions

Teams Bot Framework does not expose APIs for adding/removing reactions programmatically. The adapter can receive reaction events but cannot create them.

File Attachments

Send files via inline data URIs:
Files are sent as data URIs. For large files, consider uploading to external storage and sharing links.

Thread IDs

Teams thread IDs encode conversation ID and service URL:
The service URL varies by Teams cloud (commercial, GCC, GCC-High).

Opening DMs

Create a 1:1 conversation with a user:
The user must have interacted with the bot first (via @mention) to cache their tenantId and serviceUrl. Without cached values, openDM() will throw a validation error.

Message History

fetchMessages() requires Microsoft Graph API access with one of these permissions:
  • ChatMessage.Read.Chat
  • Chat.Read.All
  • Chat.Read.WhereInstalled
Configure appTenantId to enable Graph API access.
Fetch message history from a thread:

Platform Limits

  • Message length: 28 KB (HTML content)
  • Adaptive Card size: 28 KB total
  • File size: 4 MB via inline data URI
  • Rate limits: Teams throttling thresholds

Thread Context Caching

The adapter automatically caches:
  • User service URLs (for DM creation)
  • Tenant IDs (for Graph API calls)
  • Team GUID mappings (for channel message fetching)
Cache entries expire after 30 days and are stored in the StateAdapter.

Code Examples

Troubleshooting

  • Verify TEAMS_APP_ID and TEAMS_APP_PASSWORD are correct
  • Check that the messaging endpoint in Azure matches your webhook URL
  • Ensure the webhook URL is publicly accessible (HTTPS required)
  • Install the app to the team via Teams admin center or app store
  • @mention the bot first to establish context
  • Enable “Receive messages in channels” in app manifest
  • Add appTenantId to adapter config (required for Graph API)
  • Grant Graph API permissions in Azure AD
  • Wait for admin consent if required by your tenant
  • User must interact with bot first (via @mention) to cache tenantId
  • For SingleTenant apps, provide appTenantId in config

App Manifest

Your Teams app manifest (manifest.json) should include:
See Teams manifest schema for full reference.

Next Steps

Message Handling

Process messages and build conversation flows

Adaptive Cards

Create interactive UIs with Adaptive Cards

Bot Framework

Learn more about Azure Bot Service

State Management

Persist data across requests