🔊 Add more error logs for sendEmail block
This commit is contained in:
@ -17,6 +17,7 @@ import { decrypt } from '@typebot.io/lib/api/encryption'
|
||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||
import { updateVariables } from '@/features/variables/updateVariables'
|
||||
import { parseVariables } from '@/features/variables/parseVariables'
|
||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||
|
||||
export const createChatCompletionOpenAI = async (
|
||||
state: SessionState,
|
||||
@ -89,6 +90,11 @@ export const createChatCompletionOpenAI = async (
|
||||
}, [])
|
||||
if (newVariables.length > 0)
|
||||
newSessionState = await updateVariables(newSessionState)(newVariables)
|
||||
state.result &&
|
||||
(await saveSuccessLog({
|
||||
resultId: state.result.id,
|
||||
message: 'OpenAI block successfully executed',
|
||||
}))
|
||||
return {
|
||||
outgoingEdgeId,
|
||||
newSessionState,
|
||||
|
@ -37,23 +37,35 @@ export const executeSendEmailBlock = async (
|
||||
},
|
||||
],
|
||||
}
|
||||
await sendEmail({
|
||||
typebotId: typebot.id,
|
||||
result,
|
||||
credentialsId: options.credentialsId,
|
||||
recipients: options.recipients.map(parseVariables(variables)),
|
||||
subject: parseVariables(variables)(options.subject ?? ''),
|
||||
body: parseVariables(variables)(options.body ?? ''),
|
||||
cc: (options.cc ?? []).map(parseVariables(variables)),
|
||||
bcc: (options.bcc ?? []).map(parseVariables(variables)),
|
||||
replyTo: options.replyTo
|
||||
? parseVariables(variables)(options.replyTo)
|
||||
: undefined,
|
||||
fileUrls:
|
||||
variables.find(byId(options.attachmentsVariableId))?.value ?? undefined,
|
||||
isCustomBody: options.isCustomBody,
|
||||
isBodyCode: options.isBodyCode,
|
||||
})
|
||||
|
||||
try {
|
||||
await sendEmail({
|
||||
typebotId: typebot.id,
|
||||
result,
|
||||
credentialsId: options.credentialsId,
|
||||
recipients: options.recipients.map(parseVariables(variables)),
|
||||
subject: parseVariables(variables)(options.subject ?? ''),
|
||||
body: parseVariables(variables)(options.body ?? ''),
|
||||
cc: (options.cc ?? []).map(parseVariables(variables)),
|
||||
bcc: (options.bcc ?? []).map(parseVariables(variables)),
|
||||
replyTo: options.replyTo
|
||||
? parseVariables(variables)(options.replyTo)
|
||||
: undefined,
|
||||
fileUrls:
|
||||
variables.find(byId(options.attachmentsVariableId))?.value ?? undefined,
|
||||
isCustomBody: options.isCustomBody,
|
||||
isBodyCode: options.isBodyCode,
|
||||
})
|
||||
} catch (err) {
|
||||
await saveErrorLog({
|
||||
resultId: result.id,
|
||||
message: 'Email not sent',
|
||||
details: {
|
||||
error: err,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return { outgoingEdgeId: block.outgoingEdgeId }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user