Storie test is failing in regex prediction

Hello! I’m trying to test an user input and this user input should follow a regex pattern.

So, in NLU, my intent is defined by:

- regex: regex_phone_number
    examples: |
      - ^\(?\d{2}\)?[\s-]?[\s9]?\d{4}-?\d{4}$

    - intent: phone_number  ## If the number doesn't follow the regex pattern, another intent called "invalid_number" should appear. 
        examples: |
          - [62995346785](regex_phone_number)

in DOMAIN file, there is an entity created:

entities:
  - regex_phone_number

In STORIES file I’m doing this way:

- action: utter_send_phone_number
- or:
     - intent: disagree
     - intent: phone_number
          entities:
          - regex_phone_number
- action: continue_conversation

So, finally, my tests are like this:

   (...)
    - action: utter_ask_phone_number
    - user: |
          [61995213456](regex_phone_number)
       intent: phone_number
       - slot_was_set:
          - regex_phone_number: "61995213456" 
    - action: continue_conversation

The output from my test was:

    - action: utter_ask_phone_number
    - intent: phone_number  # predicted: invalid_number: [61995213456](regex_phone_number)

My number has the correct pattern as I check here: regex101.com/, so I don’t know what’s the problem. I checked this post but I couldn’t figure it out what’s happening.

Any help would be great!

@shaysi can you post the scenario you following and following output?

Where you set the slot regex_phone_number in domain.yml?

Sorry if it’s a noob question, but what do you mean by scenario?

I’m declaring the slot in domain.

regex_phone_number:
    type: rasa.shared.core.slots.FloatSlot
    initial_value: null
    auto_fill: true
    influence_conversation: true

@shaysi bot/user scenario. I mean. Can you also show slot mention in domain.yml please. Is the above one is your slot in domain?

yes, above is the regex_phone_number slot declared in domain

@shaysi It is a custom slot you created ? or some custom slot.py file also? Did you have enough training example in intent?

Please see this blog also Build Contextual Assistants with Rasa Forms

I hope your pipeline have RegexEntityExtractor

The scenario is:

bot (utter_send_phone_number): "Can you send me your phone number?"
user (phone_number): 62982764567
bot (action_continue_conversation): continue the form

And I’m didn’t created any custom slot… I read that post and I don’t know if it fits in my situation. https://forum.rasa.com/t/failed-test-stories-for-inform/43802

@shaysi why you mention this rather then any

regex_phone_number:
    type: rasa.shared.core.slots.FloatSlot

See this Domain and see the custom slot example. Your example look like the same.

yes, in my pipeline have RegexEntityExtractor. The bot-user flow is correct, but the tests are failing.

@shaysi

I hope you remember this video https://youtu.be/tMR1PNe0JB4 please see how this guy used regex in NLU.yml.

Yes, I remember, thanks. But the problem here now is that I’m extracting correctly and the conversation between the user and bot is going great. Only the tests are failing :frowning:

@shaysi can you share the error please?

These are the lines from my test output:

- action: utter_ask_phone_number
    - intent: phone_number  # ERROR HERE predicted: invalid_number: [61995213456](regex_phone_number)

So, it took a valid number, but classified it as a invalid_number

@shaysi check the indentation please for intent? some where you mention without - in intent?

Sure, this is my test

- story: User agree to use phone number
  steps:
    (...)
  - action: utter_send_phone_number
  - user: |
      [61995213456](regex_phone_number)
    intent: phone_number
  - slot_was_set:
    - regex_phone_number: "61995213456"

@shaysi still the same error? check all yml file http://www.yamllint.com/

yes, the same error.

And this link you sent me results in a valid yaml

@shaysi your code seem fine, do check the indentations for others too. You data validation fails right?

  • action: utter_ask_phone_number
    • intent: phone_number # predicted: invalid_number: 61995213456

yes, exactly! checked everything, but still no success