Skip to content

Commit b995cdf

Browse files
committed
Fix for contats find payload
1 parent b095465 commit b995cdf

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/whatsapp/services/chatwoot.service.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,19 +455,22 @@ export class ChatwootService {
455455
const values = this.getNumbers(query);
456456

457457
const fields = this.getSearchableFields();
458-
fields.forEach((key, index) => {
459-
const queryOperator = fields.length - 1 === index ? null : 'OR';
460-
payload.push({
461-
attribute_key: key,
462-
filter_operator: 'contains',
463-
values: values,
464-
query_operator: queryOperator,
458+
459+
fields.forEach((field, index1) => {
460+
values.forEach((number, index2) => {
461+
const queryOperator = fields.length - 1 === index1 && values.length - 1 === index2 ? null : 'OR';
462+
payload.push({
463+
attribute_key: field,
464+
filter_operator: 'contains',
465+
values: [number],
466+
query_operator: queryOperator,
467+
});
465468
});
466469
});
467470

471+
this.logger.verbose('Payload: ' + JSON.stringify(payload));
468472
return payload;
469473
}
470-
471474
public async createConversation(instance: InstanceDto, body: any) {
472475
this.logger.verbose('create conversation to instance: ' + instance.instanceName);
473476
try {

0 commit comments

Comments
 (0)