From e4fbb67833d65983b4ae380c00bb32f9b2a7d69a Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Mon, 21 Jul 2025 12:26:47 -0700 Subject: [PATCH] fix(teams-webhook): response json needs type (#741) --- apps/sim/lib/webhooks/utils.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/sim/lib/webhooks/utils.ts b/apps/sim/lib/webhooks/utils.ts index a60ca4277a..4d43f701d5 100644 --- a/apps/sim/lib/webhooks/utils.ts +++ b/apps/sim/lib/webhooks/utils.ts @@ -1491,6 +1491,18 @@ export async function processWebhook( // Since executeWorkflowFromPayload handles logging and errors internally, // we just need to return a standard success response for synchronous webhooks. // Note: The actual result isn't typically returned in the webhook response itself. + + // For Microsoft Teams outgoing webhooks, return the expected response format + if (foundWebhook.provider === 'microsoftteams') { + return NextResponse.json( + { + type: 'message', + text: 'Webhook processed successfully', + }, + { status: 200 } + ) + } + return NextResponse.json({ message: 'Webhook processed' }, { status: 200 }) } catch (error: any) { // Catch errors *before* calling executeWorkflowFromPayload (e.g., auth errors) @@ -1498,6 +1510,18 @@ export async function processWebhook( `[${requestId}] Error in processWebhook *before* execution for ${foundWebhook.id} (Execution: ${executionId})`, error ) + + // For Microsoft Teams outgoing webhooks, return the expected error format + if (foundWebhook.provider === 'microsoftteams') { + return NextResponse.json( + { + type: 'message', + text: 'Webhook processing failed', + }, + { status: 200 } + ) // Still return 200 to prevent Teams from showing additional error messages + } + return new NextResponse(`Internal Server Error: ${error.message}`, { status: 500, })