diff --git a/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ZapierSettings.tsx b/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ZapierSettings.tsx index 72f300f6c..ded9828e0 100644 --- a/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ZapierSettings.tsx +++ b/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ZapierSettings.tsx @@ -20,6 +20,7 @@ type Props = { export const ZapierSettings = ({ step }: Props) => { const { webhooks } = useTypebot() const webhook = webhooks.find(byId(step.webhookId)) + return ( { - const { webhooks } = useTypebot() - const webhook = webhooks.find(byId(webhookId)) +export const ZapierContent = ({ step }: Props) => { + const { webhooks, typebot, updateWebhook } = useTypebot() + const webhook = webhooks.find(byId(step.webhookId)) + + useEffect(() => { + if (!typebot) return + if (!webhook) { + const { webhookId } = step + const newWebhook = { + id: webhookId, + ...defaultWebhookAttributes, + typebotId: typebot.id, + } as Webhook + updateWebhook(webhookId, newWebhook) + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) if (isNotDefined(webhook?.body)) return Configure... diff --git a/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts b/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts index 6704b829e..5ef4b7640 100644 --- a/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts +++ b/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts @@ -24,7 +24,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { const { webhookId } = typebot.blocks .find(byId(blockId)) ?.steps.find(byId(stepId)) as WebhookStep - await prisma.webhook.update({ where: { id: webhookId }, data: { url } }) + await prisma.webhook.update({ + where: { id: webhookId }, + data: { url, body: '{{state}}' }, + }) return res.send({ message: 'success' }) } catch (err) {