Microsoft Teams
Agent Kernel supports integration with Microsoft Teams via the Azure Bot Framework. This allows you to deploy agents that can communicate in 1:1 chats, group chats, and Teams channels, supporting text, images, and file attachments.
How It Works
- Azure Bot Service: Acts as the bridge between the Teams client and your Agent Kernel server.
- Webhook: Your Agent Kernel server exposes a
/teams/messagesendpoint that receives activities from Azure. - Agent Processing: Incoming messages are routed to your configured Agent.
- Response: The Agent's reply is sent back to the conversation via the Bot Framework Connector.
Setup Guide
Setting up a Teams bot involves three main parts: Azure, your Agent Kernel Server, and the Teams Developer Portal.
1. Azure App Registration
- Log in to the Azure Portal.
- Go to App registrations > New registration.
- Name: Enter your bot's name (e.g., "Agent Bot").
- Supported account types: Select "Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant)".
- Click Register.
- Copy the Application (client) ID. You'll use this as
AK_TEAMS__APP_ID. - Go to Certificates & secrets > New client secret. Create one and copy the Value. You'll use this as
AK_TEAMS__APP_PASSWORD.
2. Create Azure Bot Resource
- Search for Azure Bot in the Azure Portal and click Create.
- Handle: Pick a unique handle.
- Type of App: Select Multi Tenant.
- Creation type: Use existing app registration. Paste the App ID from Step 1.
- Click Review + create.
3. Configure Webhook
- In your new Azure Bot resource, go to Configuration.
- Messaging endpoint: Enter your server's public URL +
/teams/messages.- Example:
https://your-server.com/teams/messages
- Example:
- Click Apply.
- Go to Channels and add Microsoft Teams. accepting the terms.
4. Teams Developer Portal
- Open the Developer Portal app inside Microsoft Teams.
- Create a New app.
- In App features, select Bot.
- Select an existing bot and paste your Client ID (from Step 1).
- Select scopes (Personal, Team, Group Chat) and Save.
- Go to Publish to org to submit for admin approval, or Preview in Teams to test immediately.
Configuration
Configure your Agent Kernel instance using environment variables:
# Required
export AK_TEAMS__APP_ID="your-azure-client-id"
export AK_TEAMS__APP_PASSWORD="your-azure-client-secret"
# Optional
export AK_TEAMS__TENANT_ID="your-tenant-id" # Defaults to 'common' for multi-tenant
Features
- Text Messaging: Full support for 1:1 and group conversations.
- File Attachments: Automatically downloads and processes files (PDF files only) shared in chat specific logic to handle
tempauthtokens for secure access. - Images: Supports viewing and generating images.
- Mentions: Automatically strips
@BotNamementions from the prompt.
Troubleshooting
401 Unauthorized Downloads
If the bot fails to download files:
- Ensure your bot is correctly handling the
downloadUrlprovided in the attachment payload. - Check if
Files.Read.Allapplication permission is required in Azure App Registration for your specific tenant configuration (though the defaulttempauthflow usually suffices).
Bot Not Responding
- Check Azure Bot Configuration to ensure the Messaging endpoint is correct and accessible.
- Verify your App ID and Password in environment variables match the Azure App Registration.