问题
based on the story below:
## certif deny_repeat_affirm_stop
* greet
- utter_greet
* request_certificate
- certificate_form
- form{"name": "certificate_form"}
- form{"name": null}
- utter_did_that_help
* deny
- utter_ask_again
* request_certificate
- certificate_form
- form{"name": "certificate_form"}
- form{"name": null}
- utter_did_that_help
* affirm
- utter_noworries
* goodbye
- utter_goodbye
- action_restart
i need to post (rest api) the form to an service, how can i do that from actions.py when the user affirms:
*affirm
im looking for a trick or something can help me to read the *affirm in actions.py
回答1:
You can use custom actions for that.
Your domain.yml file should look like:
intents:
- affirm
actions:
- action_affirm
Your stories.md file should look like:
* affirm
- action_affirm
You actions.py file should look like:
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
class ActionAffirm(Action):
def name(self):
return 'action_affirm'
def run(self, dispatcher, tracker, domain):
#Do Something you want
...
来源:https://stackoverflow.com/questions/59857860/how-to-handle-rasa-form-confirmation-or-denying-from-actions-py