The Microsoft Teams way
- Register a bot in Azure Bot Service and configure app credentials.
- Set up a BotFrameworkAdapter with app ID and password, plus a /api/messages endpoint.
- Handle activity types (message, conversationUpdate, invoke) with different processing logic.
- Manage turn context and the adapter's middleware pipeline.
- Deal with Teams-specific features like adaptive cards, task modules, and messaging extensions separately.
teams-agent.tsTypeScript
import { BotFrameworkAdapter } from "botbuilder"; import express from "express"; const adapter = new BotFrameworkAdapter({ appId: process.env.TEAMS_APP_ID, appPassword: process.env.TEAMS_APP_PASSWORD, }); adapter.onTurnError = async (context, error) => { console.error(error); await context.sendActivity("Something went wrong."); }; const server = express(); server.post("/api/messages", (req, res) => { adapter.processActivity(req, res, async (context) => { if (context.activity.type === "message") { const reply = await yourAgent(context.activity.text); await context.sendActivity(reply); } }); }); server.listen(3978);
teams_agent.pyPython
from botbuilder.core import BotFrameworkAdapter, TurnContext from aiohttp import web settings = BotFrameworkAdapterSettings( app_id=os.environ["TEAMS_APP_ID"], app_password=os.environ["TEAMS_APP_PASSWORD"], ) adapter = BotFrameworkAdapter(settings) async def on_message(turn_context: TurnContext): if turn_context.activity.type == "message": reply = await your_agent(turn_context.activity.text) await turn_context.send_activity(reply) app = web.Application() app.router.add_post("/api/messages", lambda req: adapter.process_activity(req, "", on_message)) web.run_app(app, port=3978)
The RouteKit way
Configure Microsoft Teams as a channel in the RouteKit dashboard. Your agent code is the same whether messages come from Microsoft Teams or any other channel.
agent.tsTypeScript
import { RouteKit } from "routekit"; const routeKit = new RouteKit(); routeKit.on("message", async (msg) => { const reply = await yourAgent(msg.text); await msg.reply(reply); });
What you skip
No botbuilder, botframework-connector, botbuilder-core or botframework-connector dependency. No Microsoft Teams-specific auth flow or message parsing. If you later add other channels, your code does not change.
Try it out
RouteKit is currently in beta. Join the waitlist to connect your agent to Microsoft Teams and every other messaging channel with one integration. Or read more about why RouteKit.