feat(channels): add microsoft teams bot framework adapter

This commit is contained in:
William Valentin
2026-02-16 02:00:14 -08:00
parent c2bd8fa313
commit 8e35d2d674
15 changed files with 455 additions and 3 deletions
+2
View File
@@ -31,6 +31,7 @@ function makeBaseConfig(): Config {
whatsapp: undefined,
matrix: undefined,
signal: undefined,
teams: undefined,
} as unknown as Config;
}
@@ -45,6 +46,7 @@ describe('discoverServices', () => {
expect.objectContaining({ name: 'telegram', status: 'not_configured' }),
expect.objectContaining({ name: 'matrix', status: 'not_configured' }),
expect.objectContaining({ name: 'signal', status: 'not_configured' }),
expect.objectContaining({ name: 'teams', status: 'not_configured' }),
expect.objectContaining({ name: 'cron', status: 'not_configured' }),
expect.objectContaining({ name: 'mcp', status: 'not_configured' }),
expect.objectContaining({ name: 'web_search', status: 'configured' }),
+1
View File
@@ -54,6 +54,7 @@ export function discoverServices(
{ key: 'whatsapp', name: 'whatsapp', description: 'WhatsApp gateway' },
{ key: 'matrix', name: 'matrix', description: 'Matrix bot' },
{ key: 'signal', name: 'signal', description: 'Signal bot (signal-cli)' },
{ key: 'teams', name: 'teams', description: 'Microsoft Teams bot' },
];
for (const { key, name, description } of channelConfigs) {
+14
View File
@@ -43,6 +43,7 @@ import type { ComponentRegistry } from '../intents/index.js';
import type { RoutingPolicy } from '../routing/index.js';
import type { ChannelRegistry } from '../channels/index.js';
import { RequestBodyTooLargeError, readRequestBody } from '../utils/httpBody.js';
import type { TeamsAdapter } from '../channels/teams/adapter.js';
export interface GatewayServerConfig {
port: number;
@@ -93,6 +94,8 @@ export interface GatewayServerConfig {
serviceType: string;
txtRecord?: Record<string, string>;
};
/** Optional Teams adapter for inbound Bot Framework activity webhooks. */
teamsHandler?: Pick<TeamsAdapter, 'handleRequest'>;
}
export class GatewayServer {
@@ -476,6 +479,12 @@ export class GatewayServer {
return;
}
// Teams Bot Framework events route — bypass gateway auth (Bot Framework posts directly)
if (this.config.teamsHandler && req.method === 'POST' && req.url?.startsWith('/teams/events')) {
await this.config.teamsHandler.handleRequest(req, res);
return;
}
// Apply auth to HTTP requests when configured
const authConfig = this.config.auth ?? {};
if (this.config.authHttp !== false && authConfig.token) {
@@ -563,6 +572,11 @@ export class GatewayServer {
this.config.gmailHandler = handler;
}
/** Set the Teams handler for inbound Bot Framework activity HTTP routes (late binding). */
setTeamsHandler(handler: Pick<TeamsAdapter, 'handleRequest'>): void {
this.config.teamsHandler = handler;
}
private async startDiscovery(host: string, port: number): Promise<void> {
const discovery = this.config.discovery;
if (!discovery?.enabled) {