Microsoft Teams
Overview
This skill helps AI agents build integrations with Microsoft Teams — from simple webhook notifications to full-featured bots and workflow automation. It covers the Microsoft Graph API for team/channel/message management, Bot Framework for conversational bots, incoming webhooks for quick notifications, Adaptive Cards for rich UI, and meeting automation.
Instructions
Choose Integration Type
| Need |
Solution |
Complexity |
| Send notifications to a channel |
Incoming Webhook |
Low |
| Read/write messages, manage teams |
Graph API |
Medium |
| Interactive bot (commands, dialogs) |
Bot Framework |
High |
| No-code automation |
Power Automate |
Low |
Incoming Webhooks (Simplest)
const WEBHOOK_URL = process.env.TEAMS_WEBHOOK_URL;
// Simple text
await fetch(WEBHOOK_URL, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: '**Production Alert**: CPU at 95% on api-server-01' }),
});
// Adaptive Card (rich formatting)
await fetch(WEBHOOK_URL, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'message',
attachments: [{
contentType: 'application/vnd.microsoft.card.adaptive',
content: {
type: 'AdaptiveCard', version: '1.5',
body: [
{ type: 'TextBlock', text: 'Deployment Complete', weight: 'Bolder', size: 'Large' },
{ type: 'FactSet', facts: [
{ title: 'Service', value: 'api-gateway' },
{ title: 'Version', value: 'v2.4.1' },
{ title: 'Environment', value: 'Production' },
]},
],
actions: [{ type: 'Action.OpenUrl', title: 'View Dashboard', url: 'https://grafana.example.com' }],
},
}],
}),
});
Graph API
import { ClientSecretCredential } from '@azure/identity';
import { Client } from '@microsoft/microsoft-graph-client';
import { TokenCredentialAuthenticationProvider } from '@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials';
// Permissions: Team.ReadBasic.All, ChannelMessage.Send, Chat.ReadWrite.All, OnlineMeetings.ReadWrite.All
const credential = new ClientSecretCredential(
process.env.AZURE_TENANT_ID, process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET
);
const authProvider = new TokenCredentialAuthenticationProvider(credential, {
scopes: ['https://graph.microsoft.com/.default'],
});
const graphClient = Client.initWithMiddleware({ authProvider });
// Create channel
await graphClient.api(`/teams/${teamId}/channels`).post({
displayName: 'Project Alpha', membershipType: 'standard',
});
// Send message with Adaptive Card
await graphClient.api(`/teams/${teamId}/channels/${channelId}/messages`).post({
body: { contentType: 'html', content: '' },
attachments: [{
id: '1', contentType: 'application/vnd.microsoft.card.adaptive',
content: JSON.stringify({
type: 'AdaptiveCard', version: '1.5',
body: [
{ type: 'TextBlock', text: 'PR #142: Add payment retry logic', weight: 'Bolder' },
{ type: 'FactSet', facts: [{ title: 'Author', value: 'Sarah Chen' }, { title: 'Tests', value: 'All passing' }] },
],
actions: [{ type: 'Action.OpenUrl', title: 'Review PR', url: 'https://github.com/org/repo/pull/142' }],
}),
}],
});
// Create online meeting
const meeting = await graphClient.api(`/users/${organizerId}/onlineMeetings`).post({
subject: 'Sprint Planning',
startDateTime: '2026-03-01T14:00:00Z', endDateTime: '2026-03-01T15:00:00Z',
participants: { attendees: [{ upn: 'sarah@example.com', role: 'attendee' }] },
});
console.log('Join URL:', meeting.joinUrl);
Bot Framework
import { ActivityHandler, TurnContext, CardFactory } from 'botbuilder';
import { BotFrameworkAdapter } from 'botbuilder';
import express from 'express';
class TeamBot extends ActivityHandler {
constructor() {
super();
this.onMessage(async (context: TurnContext, next) => {
const text = context.activity.text?.trim().toLowerCase();
if (text === 'status') {
const card = CardFactory.adaptiveCard({
type: 'AdaptiveCard', version: '1.5',
body: [
{ type: 'TextBlock', text: 'System Status', weight: 'Bolder', size: 'Large' },
{ type: 'FactSet', facts: [
{ title: 'API', value: 'Healthy (42ms)' },
{ title: 'Database', value: 'Healthy (8ms)' },
{ title: 'Queue', value: 'High (1,247 pending)' },
]},
],
});
await context.sendActivity({ attachments: [card] });
} else {
await context.sendActivity('Commands: `status` — system health, `deploy <service>` — deploy');
}
await next();
});
this.onMembersAdded(async (context, next) => {
for (const member of context.activity.membersAdded) {
if (member.id !== context.activity.recipient.id)
await context.sendActivity(`Welcome, ${member.name}! Type \`help\` to see what I can do.`);
}
await next();
});
}
}
const adapter = new BotFrameworkAdapter({
appId: process.env.MICROSOFT_APP_ID, appPassword: process.env.MICROSOFT_APP_PASSWORD,
});
const bot = new TeamBot();
const app = express();
app.post('/api/messages', (req, res) => adapter.process(req, res, (ctx) => bot.run(ctx)));
app.listen(3978);
Examples
Example 1: Set up deployment notifications via webhook
User prompt: "Send a rich notification to our Teams DevOps channel whenever a deployment completes, showing the service name, version, environment, and a link to Grafana."
The agent will:
- Get the Incoming Webhook URL from the Teams channel connector settings
- Construct an Adaptive Card with a
TextBlock header, a FactSet showing service/version/environment/time, and an Action.OpenUrl button linking to the Grafana dashboard
- POST the card payload to the webhook URL from the CI/CD pipeline's post-deployment step
- Add error handling to log failures without blocking the deployment
Example 2: Build a slash-command bot for system health checks
User prompt: "Create a Teams bot that responds to 'status' with a system health card showing API, database, and queue metrics pulled from our monitoring endpoints."
The agent will:
- Set up a Bot Framework project with
BotFrameworkAdapter and an Express server on port 3978
- Implement
onMessage handler that checks for the status command
- Fetch current metrics from the monitoring API endpoints
- Format the results as an Adaptive Card with a
FactSet and status indicators
- Register the bot in Azure Bot Service and install it in the Teams workspace
Guidelines
- Incoming webhooks for simple notifications — don't over-engineer with Graph API when a webhook does the job
- Use Adaptive Cards for any structured data — much better UX than plain text
- Graph API with application permissions for daemon services, delegated permissions for user-context apps
- Bot Framework for interactive scenarios — commands, dialogs, approval workflows
- Rate limits: Graph API allows 10,000 requests per 10 minutes per app per tenant
- Always handle
onMembersAdded in bots — send welcome message with capabilities
- Store tokens securely — Azure Key Vault or environment variables, never in code
- Test Adaptive Cards at adaptivecards.io/designer before deploying
- Use Teams Toolkit (VS Code extension) for rapid development with templates
- For high-volume messaging, use batch requests (
$batch endpoint) to reduce API calls
1---2name: microsoft-teams3description: >-4 Build bots, automate workflows, and manage Microsoft Teams programmatically5 via Microsoft Graph API. Use when someone asks to "build a Teams bot",6 "automate Teams messages", "create Teams channels", "integrate with Teams",7 "Teams webhook", "send Teams notifications", "manage Teams meetings", or8 "Teams app development". Covers Graph API for messaging, channels, meetings,9 bots with Bot Framework, incoming webhooks, and Power Automate integration.10license: Apache-2.011compatibility: >-12 Microsoft Graph API v1.0, Bot Framework SDK v4, Teams Toolkit. Requires13 Microsoft 365 tenant.14metadata:15 source: https://skillmd.com/skills/eliferjunior/microsoft-teams16 author: terminal-skills17 version: 1.0.018 category: development19 tags:20 - microsoft-teams21 - graph-api22 - bot-framework23 - microsoft-36524 - collaboration25---2627# Microsoft Teams2829## Overview3031This skill helps AI agents build integrations with Microsoft Teams — from simple webhook notifications to full-featured bots and workflow automation. It covers the Microsoft Graph API for team/channel/message management, Bot Framework for conversational bots, incoming webhooks for quick notifications, Adaptive Cards for rich UI, and meeting automation.3233## Instructions3435### Choose Integration Type3637| Need | Solution | Complexity |38|------|----------|------------|39| Send notifications to a channel | Incoming Webhook | Low |40| Read/write messages, manage teams | Graph API | Medium |41| Interactive bot (commands, dialogs) | Bot Framework | High |42| No-code automation | Power Automate | Low |4344### Incoming Webhooks (Simplest)4546```typescript47const WEBHOOK_URL = process.env.TEAMS_WEBHOOK_URL;4849// Simple text50await fetch(WEBHOOK_URL, {51 method: 'POST', headers: { 'Content-Type': 'application/json' },52 body: JSON.stringify({ text: '**Production Alert**: CPU at 95% on api-server-01' }),53});5455// Adaptive Card (rich formatting)56await fetch(WEBHOOK_URL, {57 method: 'POST', headers: { 'Content-Type': 'application/json' },58 body: JSON.stringify({59 type: 'message',60 attachments: [{61 contentType: 'application/vnd.microsoft.card.adaptive',62 content: {63 type: 'AdaptiveCard', version: '1.5',64 body: [65 { type: 'TextBlock', text: 'Deployment Complete', weight: 'Bolder', size: 'Large' },66 { type: 'FactSet', facts: [67 { title: 'Service', value: 'api-gateway' },68 { title: 'Version', value: 'v2.4.1' },69 { title: 'Environment', value: 'Production' },70 ]},71 ],72 actions: [{ type: 'Action.OpenUrl', title: 'View Dashboard', url: 'https://grafana.example.com' }],73 },74 }],75 }),76});77```7879### Graph API8081```typescript82import { ClientSecretCredential } from '@azure/identity';83import { Client } from '@microsoft/microsoft-graph-client';84import { TokenCredentialAuthenticationProvider } from '@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials';8586// Permissions: Team.ReadBasic.All, ChannelMessage.Send, Chat.ReadWrite.All, OnlineMeetings.ReadWrite.All87const credential = new ClientSecretCredential(88 process.env.AZURE_TENANT_ID, process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET89);90const authProvider = new TokenCredentialAuthenticationProvider(credential, {91 scopes: ['https://graph.microsoft.com/.default'],92});93const graphClient = Client.initWithMiddleware({ authProvider });9495// Create channel96await graphClient.api(`/teams/${teamId}/channels`).post({97 displayName: 'Project Alpha', membershipType: 'standard',98});99100// Send message with Adaptive Card101await graphClient.api(`/teams/${teamId}/channels/${channelId}/messages`).post({102 body: { contentType: 'html', content: '' },103 attachments: [{104 id: '1', contentType: 'application/vnd.microsoft.card.adaptive',105 content: JSON.stringify({106 type: 'AdaptiveCard', version: '1.5',107 body: [108 { type: 'TextBlock', text: 'PR #142: Add payment retry logic', weight: 'Bolder' },109 { type: 'FactSet', facts: [{ title: 'Author', value: 'Sarah Chen' }, { title: 'Tests', value: 'All passing' }] },110 ],111 actions: [{ type: 'Action.OpenUrl', title: 'Review PR', url: 'https://github.com/org/repo/pull/142' }],112 }),113 }],114});115116// Create online meeting117const meeting = await graphClient.api(`/users/${organizerId}/onlineMeetings`).post({118 subject: 'Sprint Planning',119 startDateTime: '2026-03-01T14:00:00Z', endDateTime: '2026-03-01T15:00:00Z',120 participants: { attendees: [{ upn: 'sarah@example.com', role: 'attendee' }] },121});122console.log('Join URL:', meeting.joinUrl);123```124125### Bot Framework126127```typescript128import { ActivityHandler, TurnContext, CardFactory } from 'botbuilder';129import { BotFrameworkAdapter } from 'botbuilder';130import express from 'express';131132class TeamBot extends ActivityHandler {133 constructor() {134 super();135 this.onMessage(async (context: TurnContext, next) => {136 const text = context.activity.text?.trim().toLowerCase();137 if (text === 'status') {138 const card = CardFactory.adaptiveCard({139 type: 'AdaptiveCard', version: '1.5',140 body: [141 { type: 'TextBlock', text: 'System Status', weight: 'Bolder', size: 'Large' },142 { type: 'FactSet', facts: [143 { title: 'API', value: 'Healthy (42ms)' },144 { title: 'Database', value: 'Healthy (8ms)' },145 { title: 'Queue', value: 'High (1,247 pending)' },146 ]},147 ],148 });149 await context.sendActivity({ attachments: [card] });150 } else {151 await context.sendActivity('Commands: `status` — system health, `deploy <service>` — deploy');152 }153 await next();154 });155 this.onMembersAdded(async (context, next) => {156 for (const member of context.activity.membersAdded) {157 if (member.id !== context.activity.recipient.id)158 await context.sendActivity(`Welcome, ${member.name}! Type \`help\` to see what I can do.`);159 }160 await next();161 });162 }163}164165const adapter = new BotFrameworkAdapter({166 appId: process.env.MICROSOFT_APP_ID, appPassword: process.env.MICROSOFT_APP_PASSWORD,167});168const bot = new TeamBot();169const app = express();170app.post('/api/messages', (req, res) => adapter.process(req, res, (ctx) => bot.run(ctx)));171app.listen(3978);172```173174## Examples175176### Example 1: Set up deployment notifications via webhook177**User prompt:** "Send a rich notification to our Teams DevOps channel whenever a deployment completes, showing the service name, version, environment, and a link to Grafana."178179The agent will:1801. Get the Incoming Webhook URL from the Teams channel connector settings1812. Construct an Adaptive Card with a `TextBlock` header, a `FactSet` showing service/version/environment/time, and an `Action.OpenUrl` button linking to the Grafana dashboard1823. POST the card payload to the webhook URL from the CI/CD pipeline's post-deployment step1834. Add error handling to log failures without blocking the deployment184185### Example 2: Build a slash-command bot for system health checks186**User prompt:** "Create a Teams bot that responds to 'status' with a system health card showing API, database, and queue metrics pulled from our monitoring endpoints."187188The agent will:1891. Set up a Bot Framework project with `BotFrameworkAdapter` and an Express server on port 39781902. Implement `onMessage` handler that checks for the `status` command1913. Fetch current metrics from the monitoring API endpoints1924. Format the results as an Adaptive Card with a `FactSet` and status indicators1935. Register the bot in Azure Bot Service and install it in the Teams workspace194195## Guidelines196197- Incoming webhooks for simple notifications — don't over-engineer with Graph API when a webhook does the job198- Use Adaptive Cards for any structured data — much better UX than plain text199- Graph API with application permissions for daemon services, delegated permissions for user-context apps200- Bot Framework for interactive scenarios — commands, dialogs, approval workflows201- Rate limits: Graph API allows 10,000 requests per 10 minutes per app per tenant202- Always handle `onMembersAdded` in bots — send welcome message with capabilities203- Store tokens securely — Azure Key Vault or environment variables, never in code204- Test Adaptive Cards at adaptivecards.io/designer before deploying205- Use Teams Toolkit (VS Code extension) for rapid development with templates206- For high-volume messaging, use batch requests (`$batch` endpoint) to reduce API calls