Reliably recognising an email address and setting slot


I have a simple form that currently only fills a single slot (more to be added) called email_address. I have an entity email_address and an intent my_email_address.

I’ve added intent examples to the nlu for my_email_address but Rasa doesn’t reliably recognise the email_address entity in the response if it doesn’t match one of the specific email address examples I have written in.

These are my intent examples in nlu.yml:

- intent: my_email_address
  examples: |
    - my email address is []{"entity":"email_address","value":""}
    - my email is []{"entity":"email_address","value":""}
    - [] is my email address{"entity":"email_address","value":""}
    - []{"entity":"email_address","value":""}
    - []{"entity":"email_address","value":""}
    - it's []{"entity":"email_address","value":""}

This is how my intents are set up in domain.yml:

  - deny
  - my_email_address:
        - email_address
        - name

And here are my slots and forms (I’ve removed a few that weren’t relevant):

    type: text
    influence_conversation: true
    type: text
    influence_conversation: false
    type: text
    influence_conversation: false

        - type: from_entity
          entity: email_address
        # Specifying from_text after from_entity will make rasa fallback to fill
        # the slot with any text the user utters, even if it can't recognise as
        # an email entity, as long as it doesn't match not_intents
        - type: from_text
          not_intent: [""deny"]

The user is asked to give their email address using a response called utter_ask_ticket_form_email_address.

The form works correctly if I use any of the examples written into stories.yml. But often if I don’t use the same values, it doesn’t correctly extract the email address.

For example, if after being asked the email address the user responds it's the email_address slot is correctly filled with

But if the user responds it's it falls back to incorrectly filling the email_address slot with it's

Do I just need to add lots and lots more intent examples with different email addresses in nlu.yml, or is there another way to reliably extract an email address?


My original post got hidden by the spam filter for a while.

Is it best to train the NLU to recognise an email address with lots of entity examples of email addresses, or is there a way to specifically define a rule for seeing something as an email address?

Hi, you could add more examples, but since email addresses have a given structure and it’s important for this to be reliable, it’s probably easiest to write a rule (you could use RegexEntityExtractor for that) or use DucklingEntityExtractor:

- name: DucklingEntityExtractor
  url: http://localhost:8000
  - email

Ideally, you’d also validate the email in a slot validation method. You can check how we do this in one of our demo bots here

@fkoerner thank you very much! Yes, using a specific entity extractor (I tried duckling and it worked well) is exactly what I needed to do.

@justyn excellent, glad to hear it!