2
0

🔊 Add more error logs for sendEmail block

This commit is contained in:
Baptiste Arnaud
2023-03-16 12:28:24 +01:00
parent cd09f1075f
commit 3d8cb40f06
6 changed files with 45 additions and 24 deletions

View File

@@ -17,6 +17,7 @@ import { decrypt } from '@typebot.io/lib/api/encryption'
import { saveErrorLog } from '@/features/logs/saveErrorLog' import { saveErrorLog } from '@/features/logs/saveErrorLog'
import { updateVariables } from '@/features/variables/updateVariables' import { updateVariables } from '@/features/variables/updateVariables'
import { parseVariables } from '@/features/variables/parseVariables' import { parseVariables } from '@/features/variables/parseVariables'
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
export const createChatCompletionOpenAI = async ( export const createChatCompletionOpenAI = async (
state: SessionState, state: SessionState,
@@ -89,6 +90,11 @@ export const createChatCompletionOpenAI = async (
}, []) }, [])
if (newVariables.length > 0) if (newVariables.length > 0)
newSessionState = await updateVariables(newSessionState)(newVariables) newSessionState = await updateVariables(newSessionState)(newVariables)
state.result &&
(await saveSuccessLog({
resultId: state.result.id,
message: 'OpenAI block successfully executed',
}))
return { return {
outgoingEdgeId, outgoingEdgeId,
newSessionState, newSessionState,

View File

@@ -37,23 +37,35 @@ export const executeSendEmailBlock = async (
}, },
], ],
} }
await sendEmail({
typebotId: typebot.id, try {
result, await sendEmail({
credentialsId: options.credentialsId, typebotId: typebot.id,
recipients: options.recipients.map(parseVariables(variables)), result,
subject: parseVariables(variables)(options.subject ?? ''), credentialsId: options.credentialsId,
body: parseVariables(variables)(options.body ?? ''), recipients: options.recipients.map(parseVariables(variables)),
cc: (options.cc ?? []).map(parseVariables(variables)), subject: parseVariables(variables)(options.subject ?? ''),
bcc: (options.bcc ?? []).map(parseVariables(variables)), body: parseVariables(variables)(options.body ?? ''),
replyTo: options.replyTo cc: (options.cc ?? []).map(parseVariables(variables)),
? parseVariables(variables)(options.replyTo) bcc: (options.bcc ?? []).map(parseVariables(variables)),
: undefined, replyTo: options.replyTo
fileUrls: ? parseVariables(variables)(options.replyTo)
variables.find(byId(options.attachmentsVariableId))?.value ?? undefined, : undefined,
isCustomBody: options.isCustomBody, fileUrls:
isBodyCode: options.isBodyCode, 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 } return { outgoingEdgeId: block.outgoingEdgeId }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/wordpress", "name": "@typebot.io/wordpress",
"version": "3.1.4", "version": "3.1.6",
"main": "index.js", "main": "index.js",
"repository": "https://github.com/baptisteArno/typebot.io", "repository": "https://github.com/baptisteArno/typebot.io",
"author": "baptisteArno", "author": "baptisteArno",
@@ -11,7 +11,7 @@
}, },
"scripts": { "scripts": {
"deploy": "pnpm copy && pnpm commit", "deploy": "pnpm copy && pnpm commit",
"copy": "svn copy ./trunk ./tags/3.1.4", "copy": "svn copy ./trunk ./tags/3.1.6",
"commit": "svn ci -m 'Support for custom apiHost'" "commit": "svn ci -m 'Fix default apiHost typo'"
} }
} }

View File

@@ -5,7 +5,7 @@ Requires at least: 5.0
Tested up to: 6.0 Tested up to: 6.0
License: GPL 2.0 License: GPL 2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.txt License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Stable Tag: 3.1.4 Stable Tag: 3.1.6
== Description == == Description ==
Collect 4x more responses with conversational apps using Typebot. Collect 4x more responses with conversational apps using Typebot.
@@ -24,6 +24,9 @@ This plugin relies on Typebot which is a tool that allows you to create conversa
3. Activate your Typebot with the "Typebot" admin button located in the sidebar 3. Activate your Typebot with the "Typebot" admin button located in the sidebar
== Changelog == == Changelog ==
= 3.1.6 =
* Fix default apiHost typo
= 3.1.4 = = 3.1.4 =
* Support for apiHost field in shortcode * Support for apiHost field in shortcode

View File

@@ -80,7 +80,7 @@ class Typebot_Public
$lib_url = "https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0/dist/web.js"; $lib_url = "https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0/dist/web.js";
$width = '100%'; $width = '100%';
$height = '500px'; $height = '500px';
$api_host = 'https://api.typebot.io'; $api_host = 'https://viewer.typebot.io';
if (array_key_exists('width', $attributes)) { if (array_key_exists('width', $attributes)) {
$width = sanitize_text_field($attributes['width']); $width = sanitize_text_field($attributes['width']);
} }

View File

@@ -3,7 +3,7 @@
/** /**
* Plugin Name: Typebot * Plugin Name: Typebot
* Description: Convert more with conversational forms * Description: Convert more with conversational forms
* Version: 3.1.4 * Version: 3.1.6
* Author: Typebot * Author: Typebot
* Author URI: http://typebot.io/ * Author URI: http://typebot.io/
* License: GPL-2.0+ * License: GPL-2.0+
@@ -16,7 +16,7 @@ if (!defined('WPINC')) {
die(); die();
} }
define('TYPEBOT_VERSION', '3.1.4'); define('TYPEBOT_VERSION', '3.1.6');
function activate_typebot() function activate_typebot()
{ {