Hi there, I have to trigger a form action so I call this inside another python function:
async def redirect_form(user_id, context=None): await agent.handle_message("customer survey", sender_id = user_id) loop.run_until_complete(redirect_form(user_id=user_id))
This triggers the form, however, form just passes and does not extract any slots.
my form action: class SurveyAction(FormAction):
def name(self) -> Text:
return "action_survey"
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return {
"slot_1": self.from_text(),
"slot_2": self.from_text()
}
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
return ["slot_1", "slot_2"]
def request_next_slot(self,dispatcher: "CollectingDispatcher",tracker: "Tracker",
domain):
for slot in self.required_slots(tracker):
if self._should_request_slot(tracker, slot):
if slot == 'slot_1':
dispatcher.utter_template("utter_ask_slot_1")
elif slot == 'slot_2':
dispatcher.utter_template("utter_ask_slot_2")
return [SlotSet("requested_slot", slot)]
return None
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict]:
userId = tracker.current_state()["sender_id"]
s1 = tracker.get_slot("slot_1")
s2 = tracker.get_slot("slot_2")
if s1 is not "":
## some requests to post
if s2 is not "":
## some requests to post
if s1 is not "" and s2 is not "":
dispatcher.utter_template("utter_submit_survey", tracker})
return []
My slots are from text so whatever user will type (feedback) will be sent to backend. Initial values of slots are None and auto-fill is false so that the agent will actually ask for it (but doesn’t)
Action server:
2021-06-02 15:04:07 DEBUG rasa_sdk.forms - Validating extracted slots: {}
2021-06-02 15:04:07 DEBUG rasa_sdk.forms - No slots left to request, all required slots are filled:
slot_1: None
slot_2: None
(sends request)
2021-06-02 15:04:07 DEBUG rasa_sdk.forms - Submitting the form 'action_survey'
2021-06-02 15:04:07 DEBUG rasa_sdk.forms - Deactivating the form 'action_survey'
2021-06-02 15:04:07 DEBUG rasa_sdk.executor - Finished running 'action_survey'
2021-06-02 15:04:08 DEBUG rasa_sdk.executor - Received request to run 'action_survey'
2021-06-02 15:04:08 DEBUG rasa_sdk.forms - There is no active form
2021-06-02 15:04:08 DEBUG rasa_sdk.forms - Activated the form 'action_survey
2021-06-02 15:04:08 DEBUG rasa_sdk.forms - Validating pre-filled required slots: {'slot_1': 'None', 'slot_2': 'None'}
The stories:
## path_survey * customer_survey - action_survey - form{"name": "action_survey"} - form{"name": null}
The slots in domain.yml:
slot_1:
auto_fill: false
initial_value: None
type: rasa.core.slots.TextSlot
slot_2:
auto_fill: false
initial_value: None
type: rasa.core.slots.TextSlot
What I have also tried:
## path_survey
* customer_survey
- action_survey
- form{"name": "action_survey"}
- slot{“requested_slot”: “slot_1”}
- slot{“requested_slot”: “slot_2”}
- form{"name": null}
I’ve also used the default request_next_slot from the documentation, when I put a debugger I realized it didn’t even go there. That’s why I hard the slots in that method.
What I’m currently trying at the moment:
- Make the slots unfeaturized instead.
- Make the required_slots slot event come before form as discussed here: [Solved] RASA FormPolicy - #8 by JulianGerhard
I also see here that there’s a default function that will raise a value error when slots aren’t working, I didn’t get that error
My problem also could be because I’m triggering an async function and looping over it manually to trigger the intent and the form which might be a problem. (?) but this is a must as I can’t expect the user to simply ask for a survey.
Note that I’m using 1.10.24.