From 8e15472e826b8b7cb4229b99478abc49cb62eaa3 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Mon, 15 Jul 2024 15:28:57 +0200 Subject: [PATCH] :children_crossing: (http) Allow for query params list Closes #1638 --- .../integrations/webhook/executeWebhookBlock.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts b/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts index 5ad41e07a1..37d6729ea2 100644 --- a/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts +++ b/packages/bot-engine/blocks/integrations/webhook/executeWebhookBlock.ts @@ -142,7 +142,8 @@ export const parseWebhookAttributes = async ({ typebot.variables ) as ExecutableHttpRequest['headers'] | undefined const queryParams = stringify( - convertKeyValueTableToObject(webhook.queryParams, typebot.variables) + convertKeyValueTableToObject(webhook.queryParams, typebot.variables, true), + { indices: false } ) const bodyContent = await getBodyContent({ body: webhook.body, @@ -325,17 +326,19 @@ const getBodyContent = async ({ export const convertKeyValueTableToObject = ( keyValues: KeyValue[] | undefined, - variables: Variable[] + variables: Variable[], + concatDuplicateInArray = false ) => { if (!keyValues) return - return keyValues.reduce((object, item) => { + return keyValues.reduce>((object, item) => { const key = parseVariables(variables)(item.key) const value = parseVariables(variables)(item.value) if (isEmpty(key) || isEmpty(value)) return object - return { - ...object, - [key]: value, - } + if (object[key] && concatDuplicateInArray) { + if (Array.isArray(object[key])) object[key].push(value) + else object[key] = [object[key], value] + } else object[key] = value + return object }, {}) }