From 25daec9f41883f2d8757712e9267946902e746c1 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Tue, 3 Sep 2024 17:23:05 -0300 Subject: [PATCH] fix: use chatwoot with evolution channel --- package.json | 1 - .../chatbot/chatwoot/services/chatwoot.service.ts | 10 +++++----- src/main.ts | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index d11afc1d..f26bae6c 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,6 @@ "@hapi/boom": "^10.0.1", "@prisma/client": "^5.15.0", "@sentry/node": "^8.28.0", - "@sentry/profiling-node": "^8.28.0", "amqplib": "^0.10.3", "axios": "^1.6.5", "baileys": "6.7.7", diff --git a/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts b/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts index 4f47dbfe..27968f47 100644 --- a/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts +++ b/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts @@ -306,10 +306,13 @@ export class ChatwootService { data = { inbox_id: inboxId, name: name || phoneNumber, - phone_number: `+${phoneNumber}`, identifier: jid, avatar_url: avatar_url, }; + + if (jid.includes('@')) { + data['phone_number'] = `+${phoneNumber}`; + } } else { data = { inbox_id: inboxId, @@ -1135,8 +1138,7 @@ export class ChatwootService { return { message: 'bot' }; } - const chatId = - body.conversation.meta.sender?.phone_number?.replace('+', '') || body.conversation.meta.sender?.identifier; + const chatId = body.conversation.meta.sender?.identifier; // Chatwoot to Whatsapp const messageReceived = body.content ? body.content @@ -1819,14 +1821,12 @@ export class ChatwootService { return; } - // fix when receiving/sending messages from whatsapp desktop with ephemeral messages enabled if (body.message?.ephemeralMessage?.message) { body.message = { ...body.message?.ephemeralMessage?.message, }; } - // Whatsapp to Chatwoot const originalMessage = await this.getConversationMessage(body.message); const bodyMessage = originalMessage ? originalMessage diff --git a/src/main.ts b/src/main.ts index 75c160ee..5204b698 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,7 +7,6 @@ import { onUnexpectedError } from '@config/error.config'; import { Logger } from '@config/logger.config'; import { ROOT_DIR } from '@config/path.config'; import * as Sentry from '@sentry/node'; -import { nodeProfilingIntegration } from '@sentry/profiling-node'; import { ServerUP } from '@utils/server-up'; import axios from 'axios'; import compression from 'compression'; @@ -30,7 +29,6 @@ async function bootstrap() { dsn: dsn, environment: process.env.NODE_ENV || 'development', tracesSampleRate: 1.0, - integrations: [nodeProfilingIntegration()], profilesSampleRate: 1.0, });