I have created a from using slots and actions. it is working with the form completion but after the form completion i dont know how to re active the form like the earlier one. stories:
happy path
- greet
- utter_greet
admission path
- affirm
- admission_form
- form{“name”: “admission_form”}
- form{“name”: null}
- utter_slots_values
- utter_ask_feedback
- utter_ask_help
admission stop
- greet
- utter_greet
- affirm
- admission_form
- form{“name”: “admission_form”}
- out_of_scope
- utter_continue
- deny
- action_deactivate_form
- form{“name”: null}
- utter_goodbye
admission continue
- greet
- utter_greet
- affirm
- admission_form
- form{“name”: “admission_form”}
- out_of_scope
- utter_continue
- affirm
- admission_form
- form{“name”: null}
- utter_slots_values
- utter_ask_feedback
- utter_ask_help
Action.py from typing import Any, Text, Dict, List,Union, Optional
from rasa_sdk import Action, Tracker from rasa_sdk.executor import CollectingDispatcher from rasa_sdk.forms import FormAction from rasa_sdk.events import AllSlotsReset from rasa_core.events import SlotSet from rasa_core.events import Restarted
from rasa_core.trackers import DialogueStateTracker
class ActionHelloWorld(FormAction):
def name(self) -> Text:
return "admission_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
return["name","ssn","subject","address"]
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return{
"name": self.from_entity(entity = "name" , intent = "name_entry"),
"ssn": self.from_entity(entity = "ssn" , intent = "ssn_entry"),
"subject":self.from_entity(entity = "subject" , intent = "subject_entry"),
"address": [self.from_text()],
}
@staticmethod
def sub_db() -> List[Text]:
return[
"python",
"visual",
"java",
"c",
"core-java",
"software",
"data",
]
def validate_subject(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]
) -> Dict[Text, Any]:
if value.lower() in self.sub_db():
return {"subject": value}
else:
dispatcher.utter_message(template="utter_wrong_subject")
return{"subject": None}
def validate_ssn(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]
) -> Dict[Text, Any]:
if len(value) == 6:
return {"ssn": value}
else:
dispatcher.utter_message(template="utter_wrong_ssn")
return{"ssn": None}
def submit(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict]:
dispatcher.utter_message(template = "utter_submit",name = tracker.get_slot("name"),subject=tracker.get_slot("subject"),
address=tracker.get_slot("address"),ssn= tracker.get_slot("ssn"))
return []
entities:
- name
- ssn
- subject
- address forms:
- admission_form intents:
- greet
- goodbye
- admission_enqiry
- name_entry
- subject_entry
- ssn_entry
- help
- address
- out_of_scope
- deny
- affirm
actions:
- action_reset_all_slots
responses: utter_ask_address: - text: “{name}, Please Enter your Address” utter_ask_continue: - text: “Sorry, I don’t quite understand. Do you want to continue?” utter_ask_feedback: - text: “please give the feedback so far” utter_ask_help: - text: “Do you want anything else {name}?” utter_ask_name: - text: “Your name please?” utter_ask_ssn: - text: "{name} Please enter your ssn number " utter_ask_subject: - buttons: - payload: “/subject_entry{“subject”:“python”}” title: python - payload: “/subject_entry{“subject”:“visual”}” title: visual - payload: “/subject_entry{“subject”:“core-java”}” title: core-java - payload: “/subject_entry{“subject”:“c”}” title: c - payload: “/subject_entry{“subject”:“java”}” title: java - payload: “/subject_entry{“subject”:“software”}” title: software text: “hi {name}, Which subject you want to take?” utter_goodbye: - text: “Bye see you next time {name}” utter_greet: - text: |- welcome to Madras University Admission!! Are you coming for the Admission?? utter_help: - text: “Thanks for your admission we will get back to you soon {name}” utter_continue: - text: “Sorry, I don’t quite understand. Do you want to continue?” utter_slots_values: - text: |- I’m going to take your admission requests with these information: - name : {name} - ssn : {ssn} - subject: {subject} - address : {address} utter_submit: - text: “All Done!!” utter_wrong_ssn: - text: “SOCIAL SECURITY KEY MUST BE IN 6 DIGITS ONLY!!!” utter_wrong_subject: - text: “THIS IS NOT AVAILABLE IN THE DATABASE!!! TRY SOME OTHER SUBJECT” utter_are_slots_ok: - text: “Continue for the another admission_enqiry?”
slots: continue: type: unfeaturized auto_fill: false address: type: unfeaturized auto_fill: false help: type: unfeaturized auto_fill: false name: type: unfeaturized auto_fill: false ssn: type: unfeaturized auto_fill: false subject: type: unfeaturized auto_fill: false
session_config: carry_over_slots_to_new_session: true session_expiration_time: 60
Can you guys please help me at the situation, i want loop the story after complted the slots or reset the slots thank you in advance