Reliably recognising an email address and setting slot

Hi

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 [example@example.com]{"entity":"email_address","value":"example@example.com"}
    - my email is [cheese@biscuits.com]{"entity":"email_address","value":"cheese@biscuits.com"}
    - [something@gmail.com] is my email address{"entity":"email_address","value":"something@gmail.com"}
    - [thing@something.com]{"entity":"email_address","value":"thing@something.com"}
    - [beans@nothing.org]{"entity":"email_address","value":"beans@nothing.org"}
    - it's [box@giraffe.co.uk]{"entity":"email_address","value":"box@giraffe.co.uk"}

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

intents:
  - deny
  - my_email_address:
      use_entities:
        - email_address
      ignore_entities:
        - name

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

slots:
  email_address:
    type: text
    influence_conversation: true
  ticket_number:
    type: text
    influence_conversation: false
  user_query:
    type: text
    influence_conversation: false


forms:
  ticket_form:
    required_slots:
      email_address:
        - 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 box@giraffe.co.uk the email_address slot is correctly filled with box@giraffe.co.uk.

But if the user responds it's chenee@gmail.com it falls back to incorrectly filling the email_address slot with it's chenee@gmail.com

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?

Thanks.

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
  dimensions:
  - 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!