feat(integration): ♿️ Add reply-to name on from field
This commit is contained in:
@@ -67,6 +67,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
resultValues: ResultValues
|
resultValues: ResultValues
|
||||||
fileUrls?: string
|
fileUrls?: string
|
||||||
}
|
}
|
||||||
|
const replyToName = replyTo?.split(' <')[0].replace(/"/g, '')
|
||||||
|
|
||||||
const { host, port, isTlsEnabled, username, password, from } =
|
const { host, port, isTlsEnabled, username, password, from } =
|
||||||
(await getEmailInfo(credentialsId)) ?? {}
|
(await getEmailInfo(credentialsId)) ?? {}
|
||||||
@@ -104,7 +105,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
}
|
}
|
||||||
const transporter = createTransport(transportConfig)
|
const transporter = createTransport(transportConfig)
|
||||||
const email: Mail.Options = {
|
const email: Mail.Options = {
|
||||||
from: `"${from.name}" <${from.email}>`,
|
from: `"${replyToName ?? from.name}" <${from.email}>`,
|
||||||
cc,
|
cc,
|
||||||
bcc,
|
bcc,
|
||||||
to: recipients,
|
to: recipients,
|
||||||
|
|||||||
@@ -294,7 +294,6 @@ const sendEmail = async (
|
|||||||
return block.outgoingEdgeId
|
return block.outgoingEdgeId
|
||||||
}
|
}
|
||||||
const { options } = block
|
const { options } = block
|
||||||
const replyTo = parseVariables(variables)(options.replyTo)
|
|
||||||
const { error } = await sendRequest({
|
const { error } = await sendRequest({
|
||||||
url: `${apiHost}/api/typebots/${typebotId}/integrations/email?resultId=${resultId}`,
|
url: `${apiHost}/api/typebots/${typebotId}/integrations/email?resultId=${resultId}`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -305,7 +304,9 @@ const sendEmail = async (
|
|||||||
body: parseVariables(variables)(options.body ?? ''),
|
body: parseVariables(variables)(options.body ?? ''),
|
||||||
cc: (options.cc ?? []).map(parseVariables(variables)),
|
cc: (options.cc ?? []).map(parseVariables(variables)),
|
||||||
bcc: (options.bcc ?? []).map(parseVariables(variables)),
|
bcc: (options.bcc ?? []).map(parseVariables(variables)),
|
||||||
replyTo: replyTo !== '' ? parseVariables(variables)(replyTo) : undefined,
|
replyTo: options.replyTo
|
||||||
|
? parseVariables(variables)(options.replyTo)
|
||||||
|
: undefined,
|
||||||
fileUrls: variables.find(byId(options.attachmentsVariableId))?.value,
|
fileUrls: variables.find(byId(options.attachmentsVariableId))?.value,
|
||||||
isCustomBody: options.isCustomBody,
|
isCustomBody: options.isCustomBody,
|
||||||
isBodyCode: options.isBodyCode,
|
isBodyCode: options.isBodyCode,
|
||||||
|
|||||||
Reference in New Issue
Block a user