feat(channels): add microsoft teams bot framework adapter
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user