refactor: chatbot integration

This commit is contained in:
Davidson Gomes 2024-08-21 13:52:09 -03:00
parent 9209c9992d
commit e7d971867b
3 changed files with 18 additions and 12 deletions

View File

@ -2010,11 +2010,13 @@ export class BaileysStartupService extends ChannelStartupService {
);
}
if (this.configService.get<Chatwoot>('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>('DATABASE').SAVE_DATA.NEW_MESSAGE)

View File

@ -923,6 +923,7 @@ export class BusinessStartupService extends ChannelStartupService {
);
}
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && isIntegration)
await chatbotController.emit({
instance: { instanceName: this.instance.name, instanceId: this.instanceId },
remoteJid: messageRaw.key.remoteJid,

View File

@ -68,17 +68,20 @@ export class ChatbotController {
remoteJid,
msg,
pushName,
isIntegration = false,
}: {
instance: InstanceDto;
remoteJid: string;
msg: any;
pushName?: string;
isIntegration?: boolean;
}): Promise<void> {
const emitData = {
instance,
remoteJid,
msg,
pushName,
isIntegration,
};
// typebot
await typebotController.emit(emitData);