Hi!
Let me describe the case
case_code : bug ID
emp_id : Id of the employee
Now i have two functions to do -
1.) translate the bug id
for this i will require only case_code
2.) assign the case_code to another emp_id.
for this i requuire both case_code and emp_id
i am giving u the snippets of code\
Stories.md-
interactive_story_1
- translate{“case_code”: “p191107-07787”}
- slot{“case_code”: “p191107-07787”}
- action_translate_issue
- slot{“case_code”: null}
story_1
-
ask_id{“emp_id”: “k.saurabh”}
- action_id
-
ask_assign
- bot_form
- form{“name”:“bot_form”}
- slot{“case_code”:“P12331-98450”}
- slot{“emp_id”:“pratush.kr”}
- form{“name”:null}
-
thankyou
- utter_happy
and more examples …
#nlu.md:
intent:plm_case_code
- [P12345-09876] (case_code)
- [P23409-76462] (case_code)
- case code is [P12345-09876] (case_code)
- case code [P23409-76462] (case_code)
- casecode [P65108-76109] (case_code)
- plm id is [P08186-60721] (case_code)
- plm case code [P69852-73145] (case_code)
- defect id is [P32198-65931] (case_code)
- defect id - [P32198-47963] (case_code)
intent:translate
- translate issues id [P190100-12345] (case_code)
- translate issue [P190100-12345] (case_code)
- translate the issue in english on [P190100-12345] (case_code)
- traslate [P190100-12345] (case_code) issue
- translate issue [P190100-12345] (case_code) to english
- translate [P190100-12345] (case_code) issue to english
- Please translate issue [P190100-12345] (case_code)
intent: ask_id
- [vi.kumar] (emp_id) … a few more examples
actions.py
class BotForm(FormAction):
def name(self):
return "bot_form"
@staticmethod
def required_slots(tracker):
return["case_code", "id"]
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked"""
return {
"case_code": [
self.from_entity(entity = "case_code", intent = "plm_case_code"),
self.from_text(intent = None)
],
"id": [
self.from_entity(entity = "id" , intent = "ask_knox_id_part_group"),
self.from_text(intent = None)
]
}
def validate_case_code(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
print("validate_case_code")
# code for validation
def validate_id(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
try:
print("validate_id")
# code for validation
def request_next_slot(
self,
dispatcher: "CollectingDispatcher",
tracker: "Tracker",
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
intent = tracker.latest_message.get("intent", {}).get("name")
print("intent name = ", intent)
for slot in self.required_slots(tracker):
if self._should_request_slot(tracker, slot):
## Condition of validated slot that triggers deactivation
if intent == "stop":
print("form will be stopped")
dispatcher.utter_message("Form will be stopped")
return self.deactivate()
print("Request next slot '{}'".format(slot))
dispatcher.utter_template("utter_ask_{}".format(slot),
tracker,
silent_fail=False,
**tracker.slots)
return [SlotSet(REQUESTED_SLOT, slot)]
print("No slots left to request")
return None
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict]:
# code for execution
My doubt is -
once intent “assign” is predicted -> bot_form is executed ->
utter_ask_case_code runs -> i provide the case_code. ->
intent “plm_case_code” is predicted
when i provide case_code , it enters into the translate intent and execute action_translate.
How to solve this so that i can execute my form successfully without a break in the flow of story.