how to handle rasa form confirmation or denying from actions.py

為{幸葍}努か 提交于 2021-01-29 22:21:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!