diff --git a/server/source/functions/send-crisp-message.ts b/server/source/functions/send-crisp-message.ts index cedacd682..01147e6e7 100644 --- a/server/source/functions/send-crisp-message.ts +++ b/server/source/functions/send-crisp-message.ts @@ -29,9 +29,9 @@ type SendMessageParamsType = { } type ConversationMetaType = { - email: string + email?: string subject: string - nickname: string + nickname?: string } type CrispType = { @@ -68,11 +68,21 @@ export const sendCrispMessage = async (body: BodyType) => { const { session_id: sessionId } = result - await CrispClient.website.updateConversationMetas(WEBSITE_ID, sessionId, { - email, - nickname: email, + const metas: ConversationMetaType = { subject, - }) + nickname: 'Utilisateur inconnu (email non renseigné)', // Default value if no email + } + + if (email) { + metas.email = email + metas.nickname = email + } + + await CrispClient.website.updateConversationMetas( + WEBSITE_ID, + sessionId, + metas + ) CrispClient.website.sendMessageInConversation( WEBSITE_ID,