> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Customer management plugin uses a search engine (for example, Elasticsearch engine) to retrieve user details using partial match on big databases.

![](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/platform-deep-dive/crm-plugin.svg)

The plugin listens for incoming requests on a Kafka topic and sends the reply to the Engine on an outgoing topic.

[Kafka topics for Customer Management](#kafka-topics-for-customer-management)

## Kafka topics for customer management

### Customer Search

> [!NOTE]
>
> The kafka topics used for the Customer Management plugin can be defined/overwritten using the following environment variables (that can be found in the deployment of the service):
>
> * `KAFKA_TOPIC_CUSTOMER_SEARCH_IN` - used to search customers in the customer management plugin
> * `KAFKA_TOPIC_CUSTOMER_SEARCH_OUT` - used to get the response from the customer management plugin to the Engine.

The request sent to the plugin can use any key that was previously configured in the Elasticsearch index where the customers are saved.

Example of an Elasticsearch index:

```json theme={"dark"}
{
  "settings": {
    "analysis": {
      "normalizer": {
        "lowercase_normalizer": {
          "type": "custom",
          "filter": ["lowercase"]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "CIF":{
        "type": "keyword",
        "normalizer": "lowercase_normalizer"
      },
      "ClientUniqueIdentifier": {
        "type": "keyword",
        "normalizer": "lowercase_normalizer"
      },
      "CNPFlex":{
        "type": "text"
      },
      "ClientType":{
        "type": "text"
      },
      "ClientCategory":{
        "type": "text"
      },
      "FirstName":{
        "type": "text",
        "fields": {
          "keyword":{
            "type": "keyword",
            "normalizer": "lowercase_normalizer"
          }
        }
      },
      "LastName":{
        "type": "text",
        "fields": {
          "keyword":{
            "type": "keyword",
            "normalizer": "lowercase_normalizer"
          }
        }
      },
      "CompanyName":{
        "type": "text",
        "fields": {
          "keyword":{
            "type": "keyword",
            "normalizer": "lowercase_normalizer"
          }
        }
      },
      "DateOfBirth":{
        "type": "date",
        "format": "dd.MM.yyyy"
      },
      "IDDocType":{
        "type": "text"
      },
      "IDSeries":{
        "type": "text"
      },
      "IDNumber":{
        "type": "text"
      },
      "IDIssueDate": {
        "type": "date",
        "format": "dd.MM.yyyy"
      },
      "IDExpiryDate":{
        "type": "date",
        "format": "dd.MM.yyyy"
      },
      "LegalForm":{
        "type": "text"
      },
      "CreatedDatePJ":{
        "type": "date",
        "format": "dd.MM.yyyy"
      },
      "ClientClosedDate": {
        "type": "date",
        "format": "dd.MM.yyyy"
      },
      "LastModifiedDate":{
        "type": "date",
        "format": "dd.MM.yyyy"
      },
      "ListID":{
        "type": "text"
      },
      "MobilePhone":{
        "type": "text"
      }
    }
  }
}

```

With this index configuration we can search for customers using any key:

## Key examples

### Example 1 - using only the "ClientUniqueIdentifier" key:

```json theme={"dark"}
{
"ClientUniqueIdentifier": "1900101223344"
}
```

### Example 2 - using "FirstName" and "LastName" keys:

```json theme={"dark"}
{
"FirstName": "TestFirstName",
"LastName": "Test Last Name"
}
```

### Example 3 - using "FirstName", "DateOfBirth" and "LegalForm" keys:

```json theme={"dark"}
{
"FirstName": "TestFirstName",
"DateOfBirth": "01.01.1990",
"LegalForm": "PF"
}
```

## Keys description

* **customers** - list of customers found in the customer management, in the used Elasticsearch index, maximum 10 results
* **hasMore** - boolean, true if number of results are bigger than 10, false if the number of results are equal or smaller than 10
* **error** - error description if the request returned an error

Topic name example:

```
ro.flowx.updates.sandbox.customer.management.response
```

Sent body example:

```json theme={"dark"}
"searchResults" : {
    "customers" : [ {
      "id" : "CL12345",
      "firstName" : "John Doe",
      "lastName" : "Doe",
      "birthDate" : "27.02.1982",
      "cui" : "1820227103865_84",
      "companyName" : "",
      "clientCategory" : "PF",
      "clientType" : "PF",
      "idSeries" : "RT",
      "idNumber" : "879948",
      "idDocType" : "CI",
      "idExpiryDate" : "27.02.2023",
      "legalForm" : "",
      "listId" : "4691602",
      "mobilePhone" : "0711111111",
      "attributes" : null,
      "type" : "PF"}],
    "hasMore" : false,
    "error" : null
  }
```


## Related topics

- [Overview](https://docs.flowx.ai/5.1/docs/platform-deep-dive/integrations/integrations-overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.