> For the complete documentation index, see [llms.txt](https://docs.borndigital.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.borndigital.ai/digital-agent/advanced-functions/data-masking.md).

# Data masking

Hide personal data – card numbers, IBANs, phone numbers, birth numbers and more – in what customers write or say in the chat bubble, before it reaches the flow, the AI and the logs.

Data masking replaces personal data in the customer's message with `[**MASKED**]` before the message reaches the flow, the AI and the conversation logs. Use it when customers may write or say card numbers, account numbers or other details that must not be stored.

{% hint style="info" %}
Masking works in conversations that run through the chat bubble – typed messages and speech in the bubble, also in mobile apps that embed it. It does not apply to phone calls.
{% endhint %}

## Switch it on

Masking is off until the flow switches it on. Set the variable `data_masking` to `true`, typically in the **START** node. From then on every customer message is masked, until the flow sets `data_masking` to `false`.

| Variable                 | Value                                         | What it does                                                              |
| ------------------------ | --------------------------------------------- | ------------------------------------------------------------------------- |
| `data_masking`           | `true` / `false`                              | Switches masking on or off for the rest of the conversation.              |
| `data_masking_detectors` | Detector names separated by commas, or a list | Masks only these types. Without it, every type except `amount` is masked. |

Both variables can change during the conversation; the new value applies to the customer's next message.

## What is masked

The detectors run in the order of this table. A value that one detector masks is not checked again by the ones below it.

| Detector        | Masks                                                                                                          | Example                                   |
| --------------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| `iban`          | IBAN of a known country with its exact length (the checksum is not checked)                                    | `SK31 1200 0000 1987 4263 7541`           |
| `email`         | E-mail addresses                                                                                               | `jana.novakova@example.com`               |
| `phone`         | Phone numbers: any valid number with `+` or `00`, otherwise Slovak and Czech numbers with at least nine digits | `+421 905 123 456`, `0905/123 456`        |
| `cardNumber`    | Card numbers with 13 to 19 digits                                                                              | `4111 1111 1111 1111`                     |
| `birthNumber`   | Birth numbers with nine or ten digits, also with `/` or `-` after the sixth digit                              | `751105/3652`                             |
| `birthDate`     | Dates from 1900 to this year, with numbers or Slovak, Czech or English month names, also written together      | `23.7.1999`, `23. júla 1999`, `23.jula99` |
| `idCard`        | ID card numbers: two letters and six digits                                                                    | `AB 123456`                               |
| `ownershipDeed` | Ownership deed (list vlastníctva) numbers after `LV`, `list vlastnictva` or `ownership deed`                   | `LV 1234`                                 |
| `cif`           | Customer numbers (CIF) after the word `CIF`, or six characters with a letter and three final digits            | `CIF 123456`, `AB1-234`                   |
| `amount`        | Amounts with a currency or after words such as `suma` – off unless you list it                                 | `1 500 EUR`                               |
| `address`       | Street names with a house number (Slovak, Czech and English streets)                                           | `Hlavná 12`                               |
| `personName`    | First and last names (Slovak, Czech and English names)                                                         | `Jana Nováková`                           |
| `numericString` | Any other number with six or more digits, for example client references and larger amounts                     | `00123456`, `1500000`                     |

If you set `data_masking_detectors`, list every type you want masked. `numericString` is not added on its own – include it if remaining long numbers should be masked too.

## What the flow and the logs see

* The flow, the AI and the logs receive `[**MASKED**]` instead of the value, so the agent cannot read or repeat the original. If the flow needs a value – a client reference it looks up, for example – leave its type out of `data_masking_detectors`, and for numbers also leave out `numericString`.
* Values the customer enters in a [Form widget](https://docs.borndigital.ai/digital-agent/advanced-functions/widgets.md) are not masked: they reach the flow as variables, and the technical logs show only their names.
* A message longer than 5,000 characters is replaced as a whole with `[MASKED_OVER_LENGTH]`.

## Example

In the **START** node:

| Variable                 | Value                                                             |
| ------------------------ | ----------------------------------------------------------------- |
| `data_masking`           | `true`                                                            |
| `data_masking_detectors` | `iban,email,phone,cardNumber,birthNumber,birthDate,numericString` |

The customer writes *"My card is 4111 1111 1111 1111, call me on +421 905 123 456."* The flow receives *"My card is \[\*\*MASKED\*\*], call me on \[\*\*MASKED\*\*]."*
