2
0

feat(bot): Custom email body and HTML content

This commit is contained in:
Baptiste Arnaud
2022-06-12 09:05:10 +02:00
parent aeaaa5c398
commit 97980f42ca
8 changed files with 358 additions and 23 deletions

View File

@ -275,7 +275,15 @@ const executeWebhook = async (
const sendEmail = async (
block: SendEmailBlock,
{ variables, apiHost, isPreview, onNewLog, resultId }: IntegrationContext
{
variables,
apiHost,
isPreview,
onNewLog,
resultId,
typebotId,
resultValues,
}: IntegrationContext
) => {
if (isPreview) {
onNewLog({
@ -288,7 +296,7 @@ const sendEmail = async (
const { options } = block
const replyTo = parseVariables(variables)(options.replyTo)
const { error } = await sendRequest({
url: `${apiHost}/api/integrations/email?resultId=${resultId}`,
url: `${apiHost}/api/typebots/${typebotId}/integrations/email?resultId=${resultId}`,
method: 'POST',
body: {
credentialsId: options.credentialsId,
@ -298,6 +306,9 @@ const sendEmail = async (
cc: (options.cc ?? []).map(parseVariables(variables)),
bcc: (options.bcc ?? []).map(parseVariables(variables)),
replyTo: replyTo !== '' ? replyTo : undefined,
isCustomBody: options.isCustomBody,
isBodyCode: options.isBodyCode,
resultValues,
},
})
onNewLog(

View File

@ -3,6 +3,8 @@ import { IntegrationBlockType, blockBaseSchema } from '../shared'
export const sendEmailOptionsSchema = z.object({
credentialsId: z.string(),
isCustomBody: z.boolean().optional(),
isBodyCode: z.boolean().optional(),
recipients: z.array(z.string()),
subject: z.string().optional(),
body: z.string().optional(),