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

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

You can just call the action_xyz when the intent *affirm is met, just as you have done in case of utter_noworries. To send a post request you should create/edit a custom action in yours actions.py file which makes a post request to any server.

i guess i have control only on forms and slots !!!?? i know how to read a slot in actions.py but how about an intent if it occurs

Can you please elaborate?

when the user fill all fields, i show them that , like here below :

rasaforum

and i ask if they want to approve, when they approve i need to do a post request (from actions.py)

the utterance of approval is like this:

utter_ask_approval:
  - text: 'Would you like to approve your request ?'
    buttons:
    - title: "approve"
      payload: '/inform{"approval":"yes"}'
    - title: "deny"
      payload: '/inform{"approval":"no"}'

I think I got it. Since you are filling the slots(yes or no) during the approval, in the custom action you can get the slot values by "tracker.get_slot(‘approval’) and based on it decide to go forward with the request or ask the user again.

Please correct me if I misunderstood the ‘approval’ slot thing.

1 Like

sorry i was mistaken, i showed you my new approach which works, and yes you’re right we can make use of tracker.get_slot(‘approval’) and do an if/else block… but it will break my logic

what i want exactly is to catch the affirm mentioned in the story mentioned earlier. affirm is an intent contrary to any entities, the latest we read them with tracker.get_slot(‘slot_name’)

If you want to get the latest intent, it should be something like:

tracker.latest_message['intent'].get('name')