Set slot right after button in action file

Hello,

I want to set the slot value with the user output value from the button. For ex:

def request_next_slot(
    self,
    dispatcher: "CollectingDispatcher",
    tracker: "Tracker",
    domain: Dict[Text, Any],
) -> Optional[List[EventType]]:

    for slot in self.required_slots(tracker):
        if self._should_request_slot(tracker, slot):
            if slot == 'animal_name':
                buttons = []
                for data in animal_kingdom:
                    buttons.append({"title": data, "payload": '/animal_name'})
                dispatcher.utter_message(
                    text="Which animal pool would you like to add to?",
                    buttons=buttons
                    )
 ---->>>>       return[SlotSet("animal_name",?)]

My query is that I want to save the output of the button that is clicked in the value of the slot. Should I define the SlotSet somewhere else because the button needs to be clicked before it can set.

Doing racker.latest_message[“text”] given me the previous message which is before the click.

Any leads?

Thanks.