# Form action doesn't ask for failed slots

**URL:** <https://forum.rasa.com/t/form-action-doesnt-ask-for-failed-slots/22421>\
**Category:** Rasa Open Source\
**Created:** [December 13, 2019, 6:26am UTC](https://forum.rasa.com/t/form-action-doesnt-ask-for-failed-slots/22421 "2019-12-13T06:26:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kabeer](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kabeer/32/5310_2.png) [@kabeer](https://forum.rasa.com/u/kabeer)\
**Post date:** [December 13, 2019, 6:26am UTC](https://forum.rasa.com/t/form-action-doesnt-ask-for-failed-slots/22421/1 "2019-12-13T06:26:41Z")

</div>

I created a `form action` to collect some personal data say `name,phone_no, dob, email`. When i enter the phone number (invalid one) i am getting below error

> Failed to extract slot phone\_no with action action\_patient\_data and bot restarts the entire conversation.

Actually it should ask for the phone number again, right?

when i type invalid phone number it matching withe other intent say `booking_number`.

**actions.py**

```
    def validate_phone_no(self,
      value: Text,
      dispatcher: CollectingDispatcher,
      tracker: Tracker,
      domain: Dict[Text,Any],
  ) -> Dict[Text,Any]:
      phone_pattern = r'(\b05\d{8}\b)'
      if re.match(phone_pattern,value):
          return {"phone_no":value}
      else:
          dispatcher.utter_message("Sorry!!!,Invalid phone number.")
          return{"phone_no":None}    

def slot_mappings(self):
    return {
    # "patient_name":self.from_text(intent="PERSON"),
    "patient_name":self.from_text(intent=None),
    "phone_no":self.from_text(intent="phone_no"),
    "dob":self.from_text(intent="date"),
    "email":self.from_text(intent="email")
    }

```

**nlu.md**

```
   ## intent:phone_no
  - [0512345678](phone_no)
  - [0512345679](phone_no)
  - [0523456789](phone_no)
  - [0534567890](phone_no)
  - [0545678901](phone_no)
  - [0512345678](phone_no)

  ## regex: phone_no
 - \b05\d{8}\b

```

How can i resolve this?

---

<div class="post-metadata">

**Author:** ![btotharye](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/btotharye/32/5321_2.png) [@btotharye](https://forum.rasa.com/u/btotharye)\
**Post date:** [December 13, 2019, 12:09pm UTC](https://forum.rasa.com/t/form-action-doesnt-ask-for-failed-slots/22421/2 "2019-12-13T12:09:35Z")

</div>

Without seeing your full action code I think it may be hard to say, do you have a validation function as well when these slots are filled? Does this only happen on invalid phone numbers? What does your validation function look like sort of like we have in our docs, [Forms](https://rasa.com/docs/rasa/core/forms/#id1)

---

<div class="post-metadata">

**Author:** ![IgNoRaNt23](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ignorant23/32/8029_2.png) [@IgNoRaNt23](https://forum.rasa.com/u/IgNoRaNt23)\
**Post date:** [December 13, 2019, 2:41pm UTC](https://forum.rasa.com/t/form-action-doesnt-ask-for-failed-slots/22421/3 "2019-12-13T14:41:38Z")

</div>

Provide some more information and maybe a sample dialogue.

You could improve your regex, for example it wont work in situation when the user says: “My phone number is 0598765432 man”. So rather use

```
\b05\d{8}\b

```

which covers both cases.

---

<div class="post-metadata">

**Author:** ![kabeer](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kabeer/32/5310_2.png) [@kabeer](https://forum.rasa.com/u/kabeer)\
**Post date:** [December 16, 2019, 9:17am UTC](https://forum.rasa.com/t/form-action-doesnt-ask-for-failed-slots/22421/4 "2019-12-16T09:17:26Z")

</div>

Yes i added validation function(included in my question).

I am trying to fill the `phone_no` slot using `"phone_no":self.from_text(intent="phone_no")`, if change this to `"phone_no":self.from_text(intent=None)` it works fine. ie, it fille the `phone_no` slot with user input and execute the `validate_` function.

Edit: Now i have the same issue with slot `email`. Current slot mapping is ` "email":self.from_text(intent="email")` and if i modify this to `"email":self.from_text(intent=None)` and a `validate_` function, it will work fine. So then what is the use of other functions in [Custom slot Mapping](https://rasa.com/docs/rasa/core/forms/#custom-slot-mappings).

And what is the use of `regex` in `nlu.md`. because i already defined a regex and i need to define avalidate funciton to check the same regex!!! Please suggest any solution…

---

<div class="post-metadata">

**Author:** ![IgNoRaNt23](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ignorant23/32/8029_2.png) [@IgNoRaNt23](https://forum.rasa.com/u/IgNoRaNt23)\
**Post date:** [December 16, 2019, 11:57am UTC](https://forum.rasa.com/t/form-action-doesnt-ask-for-failed-slots/22421/5 "2019-12-16T11:57:04Z")

</div>

You’re mixing up intents and entities. A phone number is an entity, that may appear in other contexts as well. Limiting yourself to an intent ‘phone\_no’ is definitely bad practice.

The self.from\_text mapping, should be used as a fallback, whenever your NLU component is not able to recognize entitites with high confidence. However, phone numbers and email addresses should never be a problem. Use self.from\_entity mapping instead.

You could also think about using the duckling entity extractor. It does a good job on extracting such entities.

[Entity Extraction](https://rasa.com/docs/rasa/nlu/entity-extraction/#dates-amounts-of-money-durations-distances-ordinals)

The regex in nlu.md helps the bot to correctly identitfy an entity, it is not a requirement, that has to be fullfilled.
