🚑 (webhook) Fix webhook execution with default method
This commit is contained in:
@ -43,10 +43,10 @@ export const executeWebhookBlock = async (
|
|||||||
})) as Webhook | null)
|
})) as Webhook | null)
|
||||||
: null)
|
: null)
|
||||||
if (!webhook) return { outgoingEdgeId: block.outgoingEdgeId }
|
if (!webhook) return { outgoingEdgeId: block.outgoingEdgeId }
|
||||||
const parsedWebhook = await parseWebhookAttributes(
|
const parsedWebhook = await parseWebhookAttributes(state)({
|
||||||
state,
|
webhook,
|
||||||
state.typebotsQueue[0].answers
|
isCustomBody: block.options?.isCustomBody,
|
||||||
)({ webhook, isCustomBody: block.options?.isCustomBody })
|
})
|
||||||
if (!parsedWebhook) {
|
if (!parsedWebhook) {
|
||||||
logs.push({
|
logs.push({
|
||||||
status: 'error',
|
status: 'error',
|
||||||
@ -77,7 +77,7 @@ export const executeWebhookBlock = async (
|
|||||||
const checkIfBodyIsAVariable = (body: string) => /^{{.+}}$/.test(body)
|
const checkIfBodyIsAVariable = (body: string) => /^{{.+}}$/.test(body)
|
||||||
|
|
||||||
const parseWebhookAttributes =
|
const parseWebhookAttributes =
|
||||||
(state: SessionState, answers: AnswerInSessionState[]) =>
|
(state: SessionState) =>
|
||||||
async ({
|
async ({
|
||||||
webhook,
|
webhook,
|
||||||
isCustomBody,
|
isCustomBody,
|
||||||
@ -85,7 +85,7 @@ const parseWebhookAttributes =
|
|||||||
webhook: Webhook
|
webhook: Webhook
|
||||||
isCustomBody?: boolean
|
isCustomBody?: boolean
|
||||||
}): Promise<ParsedWebhook | undefined> => {
|
}): Promise<ParsedWebhook | undefined> => {
|
||||||
if (!webhook.url || !webhook.method) return
|
if (!webhook.url) return
|
||||||
const { typebot } = state.typebotsQueue[0]
|
const { typebot } = state.typebotsQueue[0]
|
||||||
const basicAuth: { username?: string; password?: string } = {}
|
const basicAuth: { username?: string; password?: string } = {}
|
||||||
const basicAuthHeaderIdx = webhook.headers?.findIndex(
|
const basicAuthHeaderIdx = webhook.headers?.findIndex(
|
||||||
@ -114,7 +114,7 @@ const parseWebhookAttributes =
|
|||||||
)
|
)
|
||||||
const bodyContent = await getBodyContent({
|
const bodyContent = await getBodyContent({
|
||||||
body: webhook.body,
|
body: webhook.body,
|
||||||
answers,
|
answers: state.typebotsQueue[0].answers,
|
||||||
variables: typebot.variables,
|
variables: typebot.variables,
|
||||||
isCustomBody,
|
isCustomBody,
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user