Hi guys,
I am trying to use slots to fill a form and also allow the user to ask FAQs as interjections while filling it. Now, time
is defined as one of my slots and when the user asks ‘is it open today?’, the current date is extracted which should be ignored as I have set not_intent:faq
in the domain file. There is also a validator in actions.py but it gets skipped which could be used to correct this. How can we ignore the entities from FAQs and/or how to ensure that the validator gets to validate all the slots that the form gets?
Thank you!
Hi @sarthak2024, your approach sounds right, can you tell me what’s giving you trouble? What behaviour are you seeing?
Thanks for the response. The bot asks for the time of booking while the user interjects with “are you open today”. It is a faq but the bot extracts the time from “today” and puts it into a slot. As of now, I have used a fix to bypass this and only take those values which were validated.
Oh I see, that’s interesting. Is ‘is it open today?’ recognized as intent: faq
?
What do you mean by the validator gets skipped? Can you share the relevant sections of your domain (namely: where you define the form), and your validation method?
Sorry for replying late.
Yes, it is recognised as intent: faq
. The flow happens towards the end of the form as follows:
bot: When would you like to book?
user: Is it open today?
At this point, the duckling extractor extracts the time today and fills the form with it, which is not intended at this point. In the shell debugging messages, it says that it ‘skips validation’.
My form:
forms: restaurant_form: number: - type: from_entity entity: number intent: request_restaurant not_intent: faq section: - type: from_entity entity: section intent: request_restaurant not_intent: faq human_time: - type: from_entity entity: human_time intent: request_restaurant not_intent: faq time: - type: from_entity entity: time intent: request_restaurant not_intent: faq
My form validator:
class ValidateRestaurantForm(FormValidationAction): def name(self) → Text: return “validate_restaurant_form”
def validate_time( self, slot_value: Any, dispatcher: CollectingDispatcher, tracker: Tracker, domain: DomainDict, ) -> Dict[Text, Any]: """Validate time.""" booking_time = some business logic involving slot value if booking_time <= end_time and booking_time >= start_time : human_time = booking_time.strftime("%-I:%M%p").lower() return {"time":human_time} else: dispatcher.utter_message(response="utter_invalid_time") return {"time": None} def validate_number( self, slot_value: Any, dispatcher: CollectingDispatcher, tracker: Tracker, domain: DomainDict, ) -> Dict[Text, Any]: some logic
Unfortunately, I am not working on this project anymore. Though if you could find some mistake here, it would be of help to the community.
I still don’t see anything wrong, and I’m surprised that the slot is being filled despite faq
being listed as a not_intent
.
Since you’re no longer working on this I think we can let it go. If you were still working on this, I think I would have to see the debug messages to try and understand more about what is going on.
hey @sarthak2024 ,
You can user trigger_action in front of intent faq. Your problem will get solve for FAQ. For example:
intents: - ask_faq: {triggers: respond_ask_faq}
other way is to create rule in rule.yml file
for example: rules:
- rule: FAQ
steps:
- intent: faq
- action: respond_ask_faq
Hope this is simplified solution