@@ -447,29 +447,28 @@ 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 ) ;
454+ const filterPayload = [ ] ;
456455
457- const fields = this . getSearchableFields ( ) ;
456+ const numbers = this . getNumbers ( query ) ;
457+ const fieldsToSearch = this . getSearchableFields ( ) ;
458458
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 ( {
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 ( {
463463 attribute_key : field ,
464- filter_operator : 'contains ' ,
465- values : [ number ] ,
464+ filter_operator : 'equal_to ' ,
465+ values : [ number . replace ( '+' , '' ) ] ,
466466 query_operator : queryOperator ,
467467 } ) ;
468468 } ) ;
469469 } ) ;
470470
471- this . logger . verbose ( 'Payload: ' + JSON . stringify ( payload ) ) ;
472- return payload ;
471+ return filterPayload ;
473472 }
474473 public async createConversation ( instance : InstanceDto , body : any ) {
475474 this . logger . verbose ( 'create conversation to instance: ' + instance . instanceName ) ;
0 commit comments