diff --git a/apps/viewer/pages/api/typebots/[typebotId]/integrations/email.ts b/apps/viewer/pages/api/typebots/[typebotId]/integrations/email.ts index 1d688e8bf2..4e7319d753 100644 --- a/apps/viewer/pages/api/typebots/[typebotId]/integrations/email.ts +++ b/apps/viewer/pages/api/typebots/[typebotId]/integrations/email.ts @@ -10,6 +10,7 @@ import { createTransport, getTestMessageUrl } from 'nodemailer' import { decrypt, initMiddleware, + isEmpty, isNotDefined, methodNotAllowed, omit, @@ -157,7 +158,7 @@ const getEmailBody = async ({ SendEmailOptions, 'isCustomBody' | 'isBodyCode' | 'body' >): Promise<{ html?: string; text?: string } | undefined> => { - if (isCustomBody || isNotDefined(isCustomBody)) + if (isCustomBody || (isNotDefined(isCustomBody) && !isEmpty(body))) return { html: isBodyCode ? body : undefined, text: !isBodyCode ? body : undefined, diff --git a/packages/models/src/typebot/blocks/integration/sendEmail.ts b/packages/models/src/typebot/blocks/integration/sendEmail.ts index c60875debc..d102a81ad8 100644 --- a/packages/models/src/typebot/blocks/integration/sendEmail.ts +++ b/packages/models/src/typebot/blocks/integration/sendEmail.ts @@ -22,6 +22,7 @@ export const sendEmailBlockSchema = blockBaseSchema.and( export const defaultSendEmailOptions: SendEmailOptions = { credentialsId: 'default', + isCustomBody: false, recipients: [], }