mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-20 04:12:23 -06:00
fix: chatwoot integration
This commit is contained in:
@@ -333,10 +333,10 @@ export class BusinessStartupService extends ChannelStartupService {
|
||||
const mediaType = message.messages[0].document
|
||||
? 'document'
|
||||
: message.messages[0].image
|
||||
? 'image'
|
||||
: message.messages[0].audio
|
||||
? 'audio'
|
||||
: 'video';
|
||||
? 'image'
|
||||
: message.messages[0].audio
|
||||
? 'audio'
|
||||
: 'video';
|
||||
|
||||
const mimetype = result.headers['content-type'];
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ export class ChatwootService {
|
||||
avatar_url: avatar_url,
|
||||
};
|
||||
|
||||
if (jid.includes('@')) {
|
||||
if ((jid && jid.includes('@')) || !jid) {
|
||||
data['phone_number'] = `+${phoneNumber}`;
|
||||
}
|
||||
} else {
|
||||
@@ -1138,7 +1138,8 @@ export class ChatwootService {
|
||||
return { message: 'bot' };
|
||||
}
|
||||
|
||||
const chatId = body.conversation.meta.sender?.identifier;
|
||||
const chatId =
|
||||
body.conversation.meta.sender?.identifier || body.conversation.meta.sender?.phone_number.replace('+', '');
|
||||
// Chatwoot to Whatsapp
|
||||
const messageReceived = body.content
|
||||
? body.content
|
||||
|
||||
@@ -238,14 +238,14 @@ export class DifyService {
|
||||
if (data.trim() === '' || !data.startsWith('{')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const events = data.split('\n').filter((line) => line.trim() !== '');
|
||||
|
||||
|
||||
for (const eventString of events) {
|
||||
if (eventString.trim().startsWith('{')) {
|
||||
const event = JSON.parse(eventString);
|
||||
|
||||
|
||||
if (event?.event === 'agent_message') {
|
||||
console.log('event:', event);
|
||||
conversationId = conversationId ?? event?.conversation_id;
|
||||
|
||||
Reference in New Issue
Block a user