Skip to content

Commit 27ef45f

Browse files
no immediate acks for ms teams webhook (#805)
1 parent 0414aa5 commit 27ef45f

File tree

1 file changed

+14
-53
lines changed

1 file changed

+14
-53
lines changed

apps/sim/lib/webhooks/utils.ts

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ export async function executeWorkflowFromPayload(
698698
workflowVariables
699699
)
700700

701-
// Set up logging on the executor
701+
// Set up logging on the executor
702702
loggingSession.setupExecutor(executor)
703703

704704
// Log workflow execution start time for tracking
@@ -1432,45 +1432,6 @@ export async function fetchAndProcessAirtablePayloads(
14321432
/**
14331433
* Process webhook verification and authorization
14341434
*/
1435-
/**
1436-
* Handle Microsoft Teams webhooks with immediate acknowledgment
1437-
*/
1438-
async function processMicrosoftTeamsWebhook(
1439-
foundWebhook: any,
1440-
foundWorkflow: any,
1441-
input: any,
1442-
executionId: string,
1443-
requestId: string
1444-
): Promise<NextResponse> {
1445-
logger.info(
1446-
`[${requestId}] Acknowledging Microsoft Teams webhook ${foundWebhook.id} and executing workflow ${foundWorkflow.id} asynchronously (Execution: ${executionId})`
1447-
)
1448-
1449-
// Execute workflow asynchronously without waiting for completion
1450-
executeWorkflowFromPayload(
1451-
foundWorkflow,
1452-
input,
1453-
executionId,
1454-
requestId,
1455-
foundWebhook.blockId
1456-
).catch((error) => {
1457-
// Log any errors that occur during async execution
1458-
logger.error(
1459-
`[${requestId}] Error during async workflow execution for webhook ${foundWebhook.id} (Execution: ${executionId})`,
1460-
error
1461-
)
1462-
})
1463-
1464-
// Return immediate acknowledgment for Microsoft Teams
1465-
return NextResponse.json(
1466-
{
1467-
type: 'message',
1468-
text: 'Sim Studio',
1469-
},
1470-
{ status: 200 }
1471-
)
1472-
}
1473-
14741435
/**
14751436
* Handle standard webhooks with synchronous execution
14761437
*/
@@ -1494,8 +1455,18 @@ async function processStandardWebhook(
14941455
)
14951456

14961457
// Since executeWorkflowFromPayload handles logging and errors internally,
1497-
// we just need to return a standard success response for synchronous webhooks.
1498-
// Note: The actual result isn't typically returned in the webhook response itself.
1458+
// we just need to return a success response for synchronous webhooks.
1459+
// Microsoft Teams requires a specific response format.
1460+
1461+
if (foundWebhook.provider === 'microsoftteams') {
1462+
return NextResponse.json(
1463+
{
1464+
type: 'message',
1465+
text: 'Sim Studio',
1466+
},
1467+
{ status: 200 }
1468+
)
1469+
}
14991470

15001471
return NextResponse.json({ message: 'Webhook processed' }, { status: 200 })
15011472
}
@@ -1564,17 +1535,7 @@ export async function processWebhook(
15641535
return new NextResponse('No messages in WhatsApp payload', { status: 200 })
15651536
}
15661537

1567-
// --- Route to appropriate processor based on provider ---
1568-
if (foundWebhook.provider === 'microsoftteams') {
1569-
return await processMicrosoftTeamsWebhook(
1570-
foundWebhook,
1571-
foundWorkflow,
1572-
input,
1573-
executionId,
1574-
requestId
1575-
)
1576-
}
1577-
1538+
// --- Route to standard processor for all providers ---
15781539
return await processStandardWebhook(foundWebhook, foundWorkflow, input, executionId, requestId)
15791540
} catch (error: any) {
15801541
return handleWebhookError(error, foundWebhook, executionId, requestId)

0 commit comments

Comments
 (0)