# Match entities

A match entity can be detected anywhere in the conversation, meaning it is context-independent.&#x20;

## Detect information anywhere

Entities can always be asked inside a [Collect input](/buildabot/flow-logic/dialog-state/user-input-bot-dialog.md) block, but **match entities** can be detected anywhere in the conversation, which means they will skip the **Collect input** block in your flow. This would result in a conversation like this one:

![The bot now recognises the package number without asking for it](/files/-MaiGwIaqkWo_1l4CE6q)

Because you predefined the package number as a match entity, the bot was able to pick up on it in the user's expression, therefore skipping the Collect input block asking for it. The result is a much better user experience and a seemingly smarter bot 😉

## Match text or patterns

Match entities have 2 options:

* to match a [text](#match-text)
* to match a [pattern](#match-pattern)

<figure><img src="/files/JZy8SMCAzSmLGNbPrDAC" alt=""><figcaption><p>Match entities example.</p></figcaption></figure>

{% hint style="warning" %}
Note that match entities are context-independent, meaning that they can be detected at any place in the conversation. Therefore, they are very different from [contextual entities ](/nlp/natural-language-processing-nlp/detect-information-with-entities/contextual-entities.md)which are context-dependent and can be detected only at certain places inside the conversation.
{% endhint %}

### Add a match text entity

A match text entity will be detected when what the user says matches a value in a pre-defined list.

To add a Match text entity:

1. From the [Entities](/navigation/natural-language-processing-nlp/synonym-entities.md) tab, click on the **Add match entity** button.
2. Select **Match text**.
3. Enter an **Entity name**.
4. Enter different **Entity values**.
5. If you want to, add [**Synonyms**](#synonyms-in-match-text-entities) to these values by typing them in the field then clicking `Enter` on your keyboard.

<details>

<summary>Synonyms in match text entities</summary>

For each value of a matched text, you can add a synonym that will be detected as the original value. Synonyms allow you to add alternatives to entities that are assigned to the same value.&#x20;

For example:

*I want to go to Brussels*

*I want to go to Bruxelles*

The meaning of the two expressions above is exactly the same, but you want to convert *Bruxelles* to *Brussels* so your bot can work with one and the same value.

Note that match entities are case insensitive, so there's no need to add capitalized synonyms.

</details>

<figure><img src="/files/JdYFSKkNeYqLga5zxQk8" alt="" width="563"><figcaption><p>Add a match text entity.</p></figcaption></figure>

6. Click on **Create entity**.

When a user says "I want to know more about the **Premium** pack", the match entity **@product** will be recognized and saved with the value "Premium".

### Add a match pattern entity

A match pattern entity will be detected when what the user says matches a certain regular pattern.

To add a match pattern entity:

1. From the [Entities](/navigation/natural-language-processing-nlp/synonym-entities.md) tab, click on the **Add match entity** button.
2. Select **Match pattern**.
3. Add an **Entity name**.
4. Add a regular expression under **Pattern**.

<details>

<summary>Regular expressions in match pattern entities</summary>

The pattern that you fill in match pattern entities should be written as a regular expression (RegEx) Python style. For more information check <https://regex101.com/>.

For example: you have defined **@customer\_ID** as a match entity, and have provided the following regex pattern: `[a-z]{5}[0-9]{2}`. This means that when a users says "My customer ID is terwf33" – which consists of 5 letters and 2 numbers – it is saved as the match entity **@customer\_ID** with the value "terwf33".

</details>

<figure><img src="/files/LTvZuDBZGWSRC0uNeGEk" alt="" width="563"><figcaption><p>Add a match pattern entity.</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chatlayer.ai/nlp/natural-language-processing-nlp/detect-information-with-entities/match-entities.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
