From 14a37160fd7f6048f143a8a5568782a9034db1b1 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 9 Nov 2023 08:59:45 +0100 Subject: [PATCH] :ambulance: (webhook) Fix webhook execution with default method --- .../integrations/webhook/executeWebhookBlock.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts b/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts index 3f35b1bf7..d14233102 100644 --- a/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts +++ b/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts @@ -43,10 +43,10 @@ export const executeWebhookBlock = async ( })) as Webhook | null) : null) if (!webhook) return { outgoingEdgeId: block.outgoingEdgeId } - const parsedWebhook = await parseWebhookAttributes( - state, - state.typebotsQueue[0].answers - )({ webhook, isCustomBody: block.options?.isCustomBody }) + const parsedWebhook = await parseWebhookAttributes(state)({ + webhook, + isCustomBody: block.options?.isCustomBody, + }) if (!parsedWebhook) { logs.push({ status: 'error', @@ -77,7 +77,7 @@ export const executeWebhookBlock = async ( const checkIfBodyIsAVariable = (body: string) => /^{{.+}}$/.test(body) const parseWebhookAttributes = - (state: SessionState, answers: AnswerInSessionState[]) => + (state: SessionState) => async ({ webhook, isCustomBody, @@ -85,7 +85,7 @@ const parseWebhookAttributes = webhook: Webhook isCustomBody?: boolean }): Promise => { - if (!webhook.url || !webhook.method) return + if (!webhook.url) return const { typebot } = state.typebotsQueue[0] const basicAuth: { username?: string; password?: string } = {} const basicAuthHeaderIdx = webhook.headers?.findIndex( @@ -114,7 +114,7 @@ const parseWebhookAttributes = ) const bodyContent = await getBodyContent({ body: webhook.body, - answers, + answers: state.typebotsQueue[0].answers, variables: typebot.variables, isCustomBody, })