@@ -447,27 +447,29 @@ export class ChatwootService {
447447 }
448448
449449 private getSearchableFields ( ) {
450- return [ 'identifier' , ' phone_number' , 'name' , 'email '] ;
450+ return [ 'phone_number' ] ;
451451 }
452452
453453 private getFilterPayload ( query : string ) {
454- const payload = [ ] ;
455- const values = this . getNumbers ( query ) ;
456-
457- 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 ,
454+ const filterPayload = [ ] ;
455+
456+ const numbers = this . getNumbers ( query ) ;
457+ const fieldsToSearch = this . getSearchableFields ( ) ;
458+
459+ fieldsToSearch . forEach ( ( field , index1 ) => {
460+ numbers . forEach ( ( number , index2 ) => {
461+ const queryOperator = fieldsToSearch . length - 1 === index1 && numbers . length - 1 === index2 ? null : 'OR' ;
462+ filterPayload . push ( {
463+ attribute_key : field ,
464+ filter_operator : 'equal_to' ,
465+ values : [ number . replace ( '+' , '' ) ] ,
466+ query_operator : queryOperator ,
467+ } ) ;
465468 } ) ;
466469 } ) ;
467470
468- return payload ;
471+ return filterPayload ;
469472 }
470-
471473 public async createConversation ( instance : InstanceDto , body : any ) {
472474 this . logger . verbose ( 'create conversation to instance: ' + instance . instanceName ) ;
473475 try {
0 commit comments