Can I provide the user with some options through an action and use the option selected by the user in the same action?

Here is my code snippet:

class ActionCropPrice(Action):

def name(self) -> Text:

    return "action_crop_price"

def run(self, dispatcher: CollectingDispatcher,

        tracker: Tracker,

        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

    data=requests.get('https://api.data.gov.in/resource/9ef84268-d588-465a-a308-a864a43d0070?api-key=579b464db66ec23bdd0000014f4445dd136e43b87038c04d2fb819d7&format=json&offset=0&limit=10000')

    data=data.json()

    res=data['records']

    commodity=tracker.get_slot("crop")

    commodity=commodity.capitalize()

    dist=tracker.get_slot("district")

    dist=dist.capitalize()

    disFilter=[]

    cropFilter=set()

    final=[]

    cropNotSure=[]

    for i in res:

        if(i['district']==dist):

            disFilter.append(i)

            cropFilter.add(i['commodity'])

    if commodity not in cropFilter:

        for i in cropFilter:

            if(i.find(commodity)>-1):

                cropNotSure.append(i)

        if(len(cropNotSure)==0):

            dispatcher.utter_message("No results")

            return []

        else:

            buttons=[]

            for i in range(len(cropNotSure)):

                buttons.append({"title": str(i+1)+"."+cropNotSure[i],"payload":"/inform{\'opc\':  \'"+str(i+1)+"\' }"})

            dispatcher.utter_button_message("By "+commodity+", do you mean\n",buttons)

            num=tracker.get_slot("option")

            commodity=cropNotSure[int(num)-1]



            ###################################

            # This is where I'm facing a problem

            # Is it possible to get the option from the user and proceed with the code

            # If so please help me out

            # Or else give me some alternatives

            ###################################



    for i in disFilter:

        if(i['commodity']==commodity):

            final.append("Market:{}\nMaximum price:{}\nMinimum price:{}\nModal price:{}\n".format(i['market'],i['max_price'],i['min_price'],i['modal_price']))

    if(len(final)==0):

        dispatcher.utter_message("No results found")

    else:

        for i in final:

            dispatcher.utter_message(i)

    final.clear()

    return []

your buttons can contain entities that set slots, then next predicted action can use these slots to figure out what option was picked by a user

Can you please walk me through the process? Thank you

here is the docs on how to use buttons to set a slot: Slots you need to add corresponding slots to the domain. Here is an example of how to use a slot that was set before in custom action: Rasa SDK