Skip to content

Commit 6727b1c

Browse files
committed
fix: Adjusts to receive contact with more numbers
1 parent 8c7b069 commit 6727b1c

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/whatsapp/services/chatwoot.service.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,7 @@ export class ChatwootService {
11741174
const result = typeKey ? types[typeKey] : undefined;
11751175

11761176
if (typeKey === 'contactMessage') {
1177+
console.log(result);
11771178
const vCardData = result.split('\n');
11781179
const contactInfo = {};
11791180

@@ -1184,13 +1185,17 @@ export class ChatwootService {
11841185
}
11851186
});
11861187

1187-
const telKey = Object.keys(contactInfo).find((key) =>
1188-
key.startsWith('item1.TEL;waid='),
1189-
);
1188+
let formattedContact = `**Contact:**
1189+
**name:** ${contactInfo['FN']}`;
11901190

1191-
const formattedContact = `**Contact:**
1192-
**name:** ${contactInfo['FN']}
1193-
**number:** ${contactInfo[telKey]}`;
1191+
let numberCount = 1;
1192+
Object.keys(contactInfo).forEach((key) => {
1193+
if (key.startsWith('item') && key.includes('TEL;waid=')) {
1194+
const phoneNumber = contactInfo[key];
1195+
formattedContact += `\n**number ${numberCount}:** ${phoneNumber}`;
1196+
numberCount++;
1197+
}
1198+
});
11941199

11951200
this.logger.verbose('message content: ' + formattedContact);
11961201
return formattedContact;
@@ -1208,13 +1213,17 @@ export class ChatwootService {
12081213
}
12091214
});
12101215

1211-
const telKey = Object.keys(contactInfo).find((key) =>
1212-
key.startsWith('item1.TEL;waid='),
1213-
);
1216+
let formattedContact = `**Contact:**
1217+
**name:** ${contact.displayName}`;
12141218

1215-
const formattedContact = `**Contact:**
1216-
**name:** ${contact.displayName}
1217-
**number:** ${contactInfo[telKey]}`;
1219+
let numberCount = 1;
1220+
Object.keys(contactInfo).forEach((key) => {
1221+
if (key.startsWith('item') && key.includes('TEL;waid=')) {
1222+
const phoneNumber = contactInfo[key];
1223+
formattedContact += `\n**number ${numberCount}:** ${phoneNumber}`;
1224+
numberCount++;
1225+
}
1226+
});
12181227

12191228
return formattedContact;
12201229
});

0 commit comments

Comments
 (0)