Wait for user input in custom action


i have an issue with dynamically creating buttons for multiple questions after each other, similar to: How to get values from payload in button after choosing an option?

However, i have multiple questions. For now i tried to put them in a for-loop, but that returns all the questions/buttons at once, without waiting for user input. Is there a way to check for user input? like triggering “action_listen” from my custom action.

def run(self, dispatcher, tracker, domain):
    dispatcher.utter_message("Welches der Bilder entspricht dir am meisten?")
    custom_dicts = [[{"parameter1": 3*i+1,"payload": '/temporary{/"codes_tmp":/"code_'+str(3*i+1)+'/"',"title": f"Neigung {3*i+1}","typus": "image_button"},
                    {"parameter1": 3*i+2,"payload": '/temporary{/"codes_tmp":/"code_'+str(3*i+2)+'/"',"title": f"Neigung {3*i+2}","typus": "image_button"},
                    {"parameter1": 3*i+3,"payload": '/temporary{/"codes_tmp":/"code_'+str(3*i+3)+'/"',"title": f"Neigung {3*i+3}","typus": "image_button"}] for i in range(9)]

    tmp_prev = ['code_1','code_2','code_3']
    for i in custom_dicts:
        dispatcher.utter_message("Welches der Bilder entspricht dir am meisten?")
        n_prev = tracker.get_slot('n_1')

        #### here is the issue: how do i wait for the user input, before i read the slot to add the value to the list?
        n = [tracker.get_slot('codes_tmp')]
        # while not n in tmp_prev:    # this is sth i tried, wait until the slot changes
        #     print('sleep')
        #     time.sleep(10)
        # tmp_prev = tmp_prev + n

Hey @michaelh sorry for the late reply we do have a action_listen it is documented at Actions along with some of the other options you have. Might be the best thing to use here, ask for a few options, get answer, maybe give more payload, etc.

Hi @btotharye

how would i call the action_listen from within a custom function? I tried FollowupAction("action_listen "), but that did not interrupt my loop and all the questions still came at once.

We solved it now on the frontend side, but it would still be nice to solve it within Rasa :slight_smile:

Well from re-looking at this we don’t really support or recommend doing it that way. For this use case I would just use forms and set that up so it can ask for each of the different slot values then do something when they are all filled.

You can see more of this at Forms

Thank you.

I am aware that our solution is quite wonky, but we needed the custom json and the dynamic buttons and that unfortunately did not work with forms.