diff --git a/apps/docs/docs/editor/blocks/integrations/chatwoot.md b/apps/docs/docs/editor/blocks/integrations/chatwoot.md index b06e9b1093..e9f941ecc5 100644 --- a/apps/docs/docs/editor/blocks/integrations/chatwoot.md +++ b/apps/docs/docs/editor/blocks/integrations/chatwoot.md @@ -44,3 +44,9 @@ You can link the current result URL to the Chatwoot conversation by creating thi src="/img/blocks/integrations/chatwoot/custom-attribute.png" alt="Chatwoot custom attribute" /> + +### Set user behavior + +If you are prefilling user information, by default, if you leave the ID input empty, it will set the Chatwoot user ID as either the `Email` or the Result ID. + +Setting the `Email` as the ID allows us to avoid having contact not properly merged together (https://github.com/chatwoot/chatwoot/issues/2811) diff --git a/packages/bot-engine/blocks/integrations/chatwoot/executeChatwootBlock.ts b/packages/bot-engine/blocks/integrations/chatwoot/executeChatwootBlock.ts index 0128b28a1a..898620ab61 100644 --- a/packages/bot-engine/blocks/integrations/chatwoot/executeChatwootBlock.ts +++ b/packages/bot-engine/blocks/integrations/chatwoot/executeChatwootBlock.ts @@ -13,7 +13,7 @@ const parseSetUserCode = ( ) => user?.email || user?.id ? ` -window.$chatwoot.setUser(${user?.id ?? `"${resultId}"`}, { +window.$chatwoot.setUser(${user?.id ?? user.email ?? `"${resultId}"`}, { email: ${user?.email ? user.email : 'undefined'}, name: ${user?.name ? user.name : 'undefined'}, avatar_url: ${user?.avatarUrl ? user.avatarUrl : 'undefined'},