Regex to entity

@divyank have you considered using forms for that case? you can read about it in the slot filling section of our docs

@akelad I want my bot to take my Employee id and then go back to the database and fetch my user name. My bot is working fine for only those entries which i have provided in For ex.


  • My Employee id is [98987676] (person_id)

So when bot is uttering back results then it is only working for the emp id which i have given in Note i am not using regex. Please advise.

You have to give multiple examples with entities matching that regex and none without so that the bot will learn that matching that regex is a good sign for that entity.

How to use regex in Can you help ?

Here’s an example for a german zipcode

## regex:zipcode
- \b\d{5}\b

so ## regex:{entity_name} follow by the regular expression(s), you want to match. Additionaly, the RegexFeaturizer has to be part of your NLU pipeline (before your intent classifier)

That’s what the docs say

I have a Pipeline pipeline: supervised_embeddings in my config.yml. What should be the format for adding another pipeline ?

Looks likes the RegexFeaturizer is part of the supervised_embeddings pipeline per default. If the RegexFeaturizer is active, it should be mentioned in the model’s training log. If you want to be 100% sure, just copy the supervised_embedding pipeline from the docs

I tried by running this but now Bot is not returning any name. I have mentioned the following


  • [0-9]{6}

As much i understand this means from digit 0-9 repeated 6 times. Am i correct? Also after training the data i don’t see empid entry in - Found intents.

Did you add several examples like this?

## intent:example
* My Employee id is [98987676] (person_id)

Around 10 examples with person_id-entities should do the job.

btw I just noted that your example here is an 8-digit string, but your regex says 6 digits. This has to be consistent

Ok so now my training data should look like


  • [0-9]{6}
  • My empid is [123456] (person_id)
  • Here is my emp id [654321] (person_id) and so on

No, the examples sentences have to be in an intent section like usual.

do i need to mention regex name in my stories ?

No. Use the entity with regex like any other entity without a regex. Only difference is that you add the lines mentioned above.

## regex:zipcode
- \b\d{5}\b


i have tried the same thing you said @IgNoRaNt23, but still it didnot work,can you help me in this

How do you know, that it did not work?


i tried this and on putting more than 10 entries, it started working, thanks for your help. Regards, Pausali

how you configured domain file for this?

There don’t have to be any changes in the domain-file as long as the entity is specified.

It’s the same case happening for my case study when I am trying to use regex to read email id and hence send email. What can be the reason? Anyone? *It’s sending email only if I input same as in the example I gave



  • [a-zA-Z0-9_.+]+@[a-zA-Z]+[.][a-zA-Z0-9-.]+$



Welcome to the community!

You have to add several examples with different emails, otherwise Rasa thinks that the email is a constant.

## intent: affirm
- [](email)
- [](email)
- [](email)
- [](email)
... more examples ...

Also, glancing at your regex, there are a couple of things wrong with it… A domain can contain numbers (ie. and a TLD cannot contain numbers or end with a period (your regex accepts hotmail.co2m or, which are invalid).

I suggest you try your regexs here: RegularExpressions101 or somewhere like that.

Please enclose code blocks with three ` characters (or indent it with 4 spaces if your typeing), so that it’s not converted to markdown. It makes it so much easier to read.