Skip to content

Commit db065ab

Browse files
committed
fix: send media message in chatwoot
1 parent 373268c commit db065ab

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,8 +1196,10 @@ export class BaileysStartupService extends ChannelStartupService {
11961196
}
11971197

11981198
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CONTACTS)
1199-
await this.prismaRepository.contact.create({
1200-
data: contactRaw,
1199+
await this.prismaRepository.contact.upsert({
1200+
where: { remoteJid_instanceId: { remoteJid: contactRaw.remoteJid, instanceId: contactRaw.instanceId } },
1201+
create: contactRaw,
1202+
update: contactRaw,
12011203
});
12021204

12031205
return;

src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ export class ChatwootService {
540540
try {
541541
this.logger.verbose('--- Start createConversation ---');
542542
this.logger.verbose(`Instance: ${JSON.stringify(instance)}`);
543-
this.logger.verbose(`Body: ${JSON.stringify(body)}`);
544543

545544
const client = await this.clientCw(instance);
546545

@@ -1122,7 +1121,7 @@ export class ChatwootService {
11221121
data.caption = caption;
11231122
}
11241123

1125-
const messageSent = await waInstance?.mediaMessage(data, true);
1124+
const messageSent = await waInstance?.mediaMessage(data, null, true);
11261125

11271126
return messageSent;
11281127
} catch (error) {

src/api/integrations/chatbot/dify/services/dify.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ export class DifyService {
410410
media: url,
411411
caption: altText,
412412
},
413+
null,
413414
false,
414415
);
415416
}

src/api/integrations/chatbot/evolutionBot/services/evolutionBot.service.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class EvolutionBotService {
1313
private readonly waMonitor: WAMonitoringService,
1414
private readonly configService: ConfigService,
1515
private readonly prismaRepository: PrismaRepository,
16-
) { }
16+
) {}
1717

1818
private readonly logger = new Logger('EvolutionBotService');
1919

@@ -150,20 +150,18 @@ export class EvolutionBotService {
150150
delay: settings?.delayMessage || 1000,
151151
text: textBuffer.trim(),
152152
},
153-
false
153+
false,
154154
);
155155
textBuffer = '';
156156
}
157157

158158
if (mediaType === 'audio') {
159-
await instance.audioWhatsapp(
160-
{
161-
number: remoteJid.split('@')[0],
162-
delay: settings?.delayMessage || 1000,
163-
audio: url,
164-
caption: altText,
165-
}
166-
);
159+
await instance.audioWhatsapp({
160+
number: remoteJid.split('@')[0],
161+
delay: settings?.delayMessage || 1000,
162+
audio: url,
163+
caption: altText,
164+
});
167165
} else {
168166
await instance.mediaMessage(
169167
{
@@ -173,7 +171,8 @@ export class EvolutionBotService {
173171
media: url,
174172
caption: altText,
175173
},
176-
false
174+
null,
175+
false,
177176
);
178177
}
179178
} else {
@@ -197,7 +196,7 @@ export class EvolutionBotService {
197196
delay: settings?.delayMessage || 1000,
198197
text: textBuffer.trim(),
199198
},
200-
false
199+
false,
201200
);
202201
}
203202

@@ -214,7 +213,6 @@ export class EvolutionBotService {
214213
});
215214
}
216215

217-
218216
private async initNewSession(
219217
instance: any,
220218
remoteJid: string,

src/api/integrations/chatbot/flowise/services/flowise.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export class FlowiseService {
171171
media: url,
172172
caption: altText,
173173
},
174+
null,
174175
false,
175176
);
176177
}

src/api/integrations/chatbot/openai/services/openai.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export class OpenaiService {
216216
media: url,
217217
caption: altText,
218218
},
219+
null,
219220
false,
220221
);
221222
}

src/api/integrations/chatbot/typebot/services/typebot.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ export class TypebotService {
243243
mediatype: 'image',
244244
media: message.content.url,
245245
},
246+
null,
246247
false,
247248
);
248249

@@ -257,6 +258,7 @@ export class TypebotService {
257258
mediatype: 'video',
258259
media: message.content.url,
259260
},
261+
null,
260262
false,
261263
);
262264

0 commit comments

Comments
 (0)