fix: send media message in chatwoot

This commit is contained in:
Davidson Gomes 2024-10-04 17:14:12 -03:00
parent 373268c938
commit db065ab942
7 changed files with 21 additions and 17 deletions

View File

@ -1196,8 +1196,10 @@ export class BaileysStartupService extends ChannelStartupService {
}
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CONTACTS)
await this.prismaRepository.contact.create({
data: contactRaw,
await this.prismaRepository.contact.upsert({
where: { remoteJid_instanceId: { remoteJid: contactRaw.remoteJid, instanceId: contactRaw.instanceId } },
create: contactRaw,
update: contactRaw,
});
return;

View File

@ -540,7 +540,6 @@ export class ChatwootService {
try {
this.logger.verbose('--- Start createConversation ---');
this.logger.verbose(`Instance: ${JSON.stringify(instance)}`);
this.logger.verbose(`Body: ${JSON.stringify(body)}`);
const client = await this.clientCw(instance);
@ -1122,7 +1121,7 @@ export class ChatwootService {
data.caption = caption;
}
const messageSent = await waInstance?.mediaMessage(data, true);
const messageSent = await waInstance?.mediaMessage(data, null, true);
return messageSent;
} catch (error) {

View File

@ -410,6 +410,7 @@ export class DifyService {
media: url,
caption: altText,
},
null,
false,
);
}

View File

@ -13,7 +13,7 @@ export class EvolutionBotService {
private readonly waMonitor: WAMonitoringService,
private readonly configService: ConfigService,
private readonly prismaRepository: PrismaRepository,
) { }
) {}
private readonly logger = new Logger('EvolutionBotService');
@ -150,20 +150,18 @@ export class EvolutionBotService {
delay: settings?.delayMessage || 1000,
text: textBuffer.trim(),
},
false
false,
);
textBuffer = '';
}
if (mediaType === 'audio') {
await instance.audioWhatsapp(
{
number: remoteJid.split('@')[0],
delay: settings?.delayMessage || 1000,
audio: url,
caption: altText,
}
);
await instance.audioWhatsapp({
number: remoteJid.split('@')[0],
delay: settings?.delayMessage || 1000,
audio: url,
caption: altText,
});
} else {
await instance.mediaMessage(
{
@ -173,7 +171,8 @@ export class EvolutionBotService {
media: url,
caption: altText,
},
false
null,
false,
);
}
} else {
@ -197,7 +196,7 @@ export class EvolutionBotService {
delay: settings?.delayMessage || 1000,
text: textBuffer.trim(),
},
false
false,
);
}
@ -214,7 +213,6 @@ export class EvolutionBotService {
});
}
private async initNewSession(
instance: any,
remoteJid: string,

View File

@ -171,6 +171,7 @@ export class FlowiseService {
media: url,
caption: altText,
},
null,
false,
);
}

View File

@ -216,6 +216,7 @@ export class OpenaiService {
media: url,
caption: altText,
},
null,
false,
);
}

View File

@ -243,6 +243,7 @@ export class TypebotService {
mediatype: 'image',
media: message.content.url,
},
null,
false,
);
@ -257,6 +258,7 @@ export class TypebotService {
mediatype: 'video',
media: message.content.url,
},
null,
false,
);