@ -84,6 +84,8 @@ const prepareWebhookAttributes = (
|
|||||||
return webhook
|
return webhook
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bodyIsSingleVariable = (body: string) => /{{.+}}/.test(body)
|
||||||
|
|
||||||
export const executeWebhook =
|
export const executeWebhook =
|
||||||
(typebot: Typebot) =>
|
(typebot: Typebot) =>
|
||||||
async (
|
async (
|
||||||
@ -143,13 +145,17 @@ export const executeWebhook =
|
|||||||
json:
|
json:
|
||||||
contentType !== 'x-www-form-urlencoded' && body
|
contentType !== 'x-www-form-urlencoded' && body
|
||||||
? safeJsonParse(
|
? safeJsonParse(
|
||||||
parseVariables(variables, { escapeForJson: true })(body)
|
parseVariables(variables, {
|
||||||
|
escapeForJson: !bodyIsSingleVariable(body),
|
||||||
|
})(body)
|
||||||
)
|
)
|
||||||
: undefined,
|
: undefined,
|
||||||
form:
|
form:
|
||||||
contentType === 'x-www-form-urlencoded' && body
|
contentType === 'x-www-form-urlencoded' && body
|
||||||
? safeJsonParse(
|
? safeJsonParse(
|
||||||
parseVariables(variables, { escapeForJson: true })(body)
|
parseVariables(variables, {
|
||||||
|
escapeForJson: !bodyIsSingleVariable(body),
|
||||||
|
})(body)
|
||||||
)
|
)
|
||||||
: undefined,
|
: undefined,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user