How to reset slot in form after request to extarnal API

Hi, I want to create register form with 4 slots. After slots are filled I want to make request to external API with data from slots. How to handle situation when the response is for example: 409 ALREADY USED EMAIL? In this scenario I want to reset email slot after this request and go back to the form. But my problem is that there is no place in form to make request and not leave form. I can make this request only when all slots are filled. Also I want this to work in a loop (user can provide already used email more than one time).

Is there any way of solving this situation without creating loops with checkpoints?

Hi @kaladin,

I think there are several possibilities to handle this:

  1. Use the validator-method of the last slot after it has been filled to submit and get the feedback. If it fails like in your scenario, reset the form, the slots or proceed the way you want.
  2. Overwrite the validate_slots-method in your actions.py if you don’t want to do it on slot-level as mentioned in option 1.
  3. Handle this with a custom action in the story:
    ## explain cuisine slot
    * request_restaurant
        - restaurant_form
        - form{"name": "restaurant_form"}
        - slot{"requested_slot": "cuisine"}
        - action_draft_submit_form
  1. Draft submit your form content / slot content after every slot-validation

They all have advantages and disadvantages but maybe one of them suits your needs!?

Regards Julian

1 Like