diff --git a/src/api/integrations/channel/whatsapp/baileys/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/baileys/whatsapp.baileys.service.ts index f1c0378a..48be6750 100644 --- a/src/api/integrations/channel/whatsapp/baileys/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/baileys/whatsapp.baileys.service.ts @@ -2010,12 +2010,14 @@ export class BaileysStartupService extends ChannelStartupService { ); } - await chatbotController.emit({ - instance: { instanceName: this.instance.name, instanceId: this.instanceId }, - remoteJid: messageRaw.key.remoteJid, - msg: messageRaw, - pushName: messageRaw.pushName, - }); + if (this.configService.get('CHATWOOT').ENABLED && this.localChatwoot.enabled && isIntegration) + await chatbotController.emit({ + instance: { instanceName: this.instance.name, instanceId: this.instanceId }, + remoteJid: messageRaw.key.remoteJid, + msg: messageRaw, + pushName: messageRaw.pushName, + isIntegration, + }); if (this.configService.get('DATABASE').SAVE_DATA.NEW_MESSAGE) await this.prismaRepository.message.create({ diff --git a/src/api/integrations/channel/whatsapp/business/whatsapp.business.service.ts b/src/api/integrations/channel/whatsapp/business/whatsapp.business.service.ts index f6b4b56e..127adb81 100644 --- a/src/api/integrations/channel/whatsapp/business/whatsapp.business.service.ts +++ b/src/api/integrations/channel/whatsapp/business/whatsapp.business.service.ts @@ -923,12 +923,13 @@ export class BusinessStartupService extends ChannelStartupService { ); } - await chatbotController.emit({ - instance: { instanceName: this.instance.name, instanceId: this.instanceId }, - remoteJid: messageRaw.key.remoteJid, - msg: messageRaw, - pushName: messageRaw.pushName, - }); + if (this.configService.get('CHATWOOT').ENABLED && this.localChatwoot.enabled && isIntegration) + await chatbotController.emit({ + instance: { instanceName: this.instance.name, instanceId: this.instanceId }, + remoteJid: messageRaw.key.remoteJid, + msg: messageRaw, + pushName: messageRaw.pushName, + }); await this.prismaRepository.message.create({ data: messageRaw, diff --git a/src/api/integrations/chatbot/chatbot.controller.ts b/src/api/integrations/chatbot/chatbot.controller.ts index 7054f4f9..75aa4962 100644 --- a/src/api/integrations/chatbot/chatbot.controller.ts +++ b/src/api/integrations/chatbot/chatbot.controller.ts @@ -68,17 +68,20 @@ export class ChatbotController { remoteJid, msg, pushName, + isIntegration = false, }: { instance: InstanceDto; remoteJid: string; msg: any; pushName?: string; + isIntegration?: boolean; }): Promise { const emitData = { instance, remoteJid, msg, pushName, + isIntegration, }; // typebot await typebotController.emit(emitData);