Setting slot either in custom action or by calling a form if the value is not yet set

I have a value that I either want to set using logic in the code (if sufficient information is available), otherwise I want to use a form to get the information from the user. The value is also a boolean that should influence the conversation flow.

The system can make a recommendation. In some instances it will need to check some other information before deciding whether to give the recommendation.

This information can be gleaned from existing slots in some cases, in others it will need to be asked explicitly.

I’m trying to achieve the following process:

check_approved can be established based on information provided, i.e. SlotSet("check_approved", True) can be set in a custom action. If it’s not been set then I trigger a form check_form to ask a yes/no question and set check_approved accordingly.

domain.yml

  check_approved:
    type: bool

if check_approved has been already set, then I want to jump straight to action_give_recc or action_exit if not I want to run the form check_form and then route accordingly for whether check_approved is set to True or False in the form.

I thought it should work using the following stories, but if check_approved is set using the custom action then I get the fallback statement (“sorry, I didn’t understand you, please try input something else”).

Grateful for any help with getting this to work.

stories.md

## story1
    > main_conversation
    - slot{"recc_available": true}
    - check_form
    - form{"name": "check_form"}
    - form{"name": null}
    - slot{"check_approved": true}
    - action_give_recc

## story2
    > main_conversation
    - slot{"recc_available": true}
    - check_form
    - form{"name": "check_form"}
    - form{"name": null}
    - slot{"check_approved": false}
    - action_exit

if your custom action sets a slot, you need to explicitly add slot set event to the stories:

- check_form
- slot{"check_approved": true}

please see the docs: Slots