mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
feat: Send contact array in chatwoot
This commit is contained in:
parent
b3e213c133
commit
69e1622e82
@ -7,6 +7,7 @@
|
|||||||
* Created automation for creating instances in the chatwoot bot with the command '#inbox_whatsapp:<INSTANCE_NAME>'
|
* Created automation for creating instances in the chatwoot bot with the command '#inbox_whatsapp:<INSTANCE_NAME>'
|
||||||
* Change Baileys version to: 6.4.0
|
* Change Baileys version to: 6.4.0
|
||||||
* Send contact in chatwoot
|
* Send contact in chatwoot
|
||||||
|
* Send contact array in chatwoot
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -1159,6 +1159,7 @@ export class ChatwootService {
|
|||||||
msg.documentWithCaptionMessage?.message?.documentMessage?.caption,
|
msg.documentWithCaptionMessage?.message?.documentMessage?.caption,
|
||||||
audioMessage: msg.audioMessage?.caption,
|
audioMessage: msg.audioMessage?.caption,
|
||||||
contactMessage: msg.contactMessage?.vcard,
|
contactMessage: msg.contactMessage?.vcard,
|
||||||
|
contactsArrayMessage: msg.contactsArrayMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.logger.verbose('type message: ' + types);
|
this.logger.verbose('type message: ' + types);
|
||||||
@ -1183,14 +1184,48 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const telKey = Object.keys(contactInfo).find((key) =>
|
||||||
|
key.startsWith('item1.TEL;waid='),
|
||||||
|
);
|
||||||
|
|
||||||
const formattedContact = `**Contact:**
|
const formattedContact = `**Contact:**
|
||||||
**name:** ${contactInfo['FN']}
|
**name:** ${contactInfo['FN']}
|
||||||
**number:** ${contactInfo['item1.TEL;waid=5511952801378']}`;
|
**number:** ${contactInfo[telKey]}`;
|
||||||
|
|
||||||
this.logger.verbose('message content: ' + formattedContact);
|
this.logger.verbose('message content: ' + formattedContact);
|
||||||
return formattedContact;
|
return formattedContact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeKey === 'contactsArrayMessage') {
|
||||||
|
const formattedContacts = result.contacts.map((contact) => {
|
||||||
|
const vCardData = contact.vcard.split('\n');
|
||||||
|
const contactInfo = {};
|
||||||
|
|
||||||
|
vCardData.forEach((line) => {
|
||||||
|
const [key, value] = line.split(':');
|
||||||
|
if (key && value) {
|
||||||
|
contactInfo[key] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const telKey = Object.keys(contactInfo).find((key) =>
|
||||||
|
key.startsWith('item1.TEL;waid='),
|
||||||
|
);
|
||||||
|
|
||||||
|
const formattedContact = `**Contact:**
|
||||||
|
**name:** ${contact.displayName}
|
||||||
|
**number:** ${contactInfo[telKey]}`;
|
||||||
|
|
||||||
|
return formattedContact;
|
||||||
|
});
|
||||||
|
|
||||||
|
const formattedContactsArray = formattedContacts.join('\n\n');
|
||||||
|
|
||||||
|
this.logger.verbose('formatted contacts: ' + formattedContactsArray);
|
||||||
|
|
||||||
|
return formattedContactsArray;
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.verbose('message content: ' + result);
|
this.logger.verbose('message content: ' + result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -1201,12 +1236,8 @@ export class ChatwootService {
|
|||||||
|
|
||||||
const types = this.getTypeMessage(msg);
|
const types = this.getTypeMessage(msg);
|
||||||
|
|
||||||
console.log('types', types);
|
|
||||||
|
|
||||||
const messageContent = this.getMessageContent(types);
|
const messageContent = this.getMessageContent(types);
|
||||||
|
|
||||||
console.log('messageContent', messageContent);
|
|
||||||
|
|
||||||
this.logger.verbose('conversation message: ' + messageContent);
|
this.logger.verbose('conversation message: ' + messageContent);
|
||||||
|
|
||||||
return messageContent;
|
return messageContent;
|
||||||
@ -1457,7 +1488,7 @@ export class ChatwootService {
|
|||||||
|
|
||||||
if (event === 'connection.update') {
|
if (event === 'connection.update') {
|
||||||
this.logger.verbose('event connection.update');
|
this.logger.verbose('event connection.update');
|
||||||
console.log('connection.update', body);
|
|
||||||
if (body.status === 'open') {
|
if (body.status === 'open') {
|
||||||
const msgConnection = `🚀 Conexão estabelecida com sucesso!`;
|
const msgConnection = `🚀 Conexão estabelecida com sucesso!`;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user