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({ await chatbotController.emit({
instance: { instanceName: this.instance.name, instanceId: this.instanceId }, instance: { instanceName: this.instance.name, instanceId: this.instanceId },
remoteJid: messageRaw.key.remoteJid, remoteJid: messageRaw.key.remoteJid,
msg: messageRaw, msg: messageRaw,
pushName: messageRaw.pushName, pushName: messageRaw.pushName,
isIntegration,
}); });
if (this.configService.get<Database>('DATABASE').SAVE_DATA.NEW_MESSAGE) 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({ await chatbotController.emit({
instance: { instanceName: this.instance.name, instanceId: this.instanceId }, instance: { instanceName: this.instance.name, instanceId: this.instanceId },
remoteJid: messageRaw.key.remoteJid, remoteJid: messageRaw.key.remoteJid,

View File

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