How to get the button Payload or Title value

Hey, how to store the button payload to title value from a custom action I have tried with the tracker.latest_message[‘text’] but it was not helpful to me.

My scenario is, I was making an API get call where I will display available doctors as buttons(and in every get call doctors’ names will be changed), My question is how to get the Payload or Title value that the user is selecting using custom actions.

Please help me I was stuck in this position.

Thank you in Advance

Hi, what is your current implementation of the custom actions?

In Custom action i was displaying Buttons using API call

Can you show the code of your current implementation?

You can use,

button = { 'title': word, 'payload': '/intent_name{'entity_name':"'+word+'"}'}

Add a custom action after this step where you can use,

doctor_name = next(tracker.get_latest_entity_values('entity_name'))

Okay, i will try it

once see this action here i was creating intent name from API , now how can I store the Payload or Title to a Slot.

class ActionidSubmit(Action):

    def name(self) -> Text:
        return "action_book_appointment_submit"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        user_msg = tracker.latest_message.get('text')
        print(tracker.get_slot("consulttype"))
        buttons=[]
        message=Get_Doctors(tracker.get_slot("id"),tracker.get_slot("consulttype"))
        print(message)
        for word in message.split(','):
            button = {'title': word, 'payload': '/'+word+'{"Dname": "' + word + '"}'}
            buttons.append(button)
        dispatcher.utter_message(text="Your top 5 previous doctors are:",buttons=buttons)                
        return []

And in Every Api call the doctor names will be changed

You have to change this,

to,

button = { 'title': word, 'payload': '/intent_name{'Dname':"'+word+'"}'}  # add intent_name to domain

or you can directly use,

button = { 'title': word, 'payload': word} 

For this one what will be the story to store the payload

if I use this how can I store the payload or title value image

button = { 'title': word, 'payload': word}

Add a custom action after this step where you can use,

doctor_name = tracker.latest_message.get('text')

I followed the same but it is returning None

Please provide your implementation

class ActionidSubmit(Action):

    def name(self) -> Text:
        return "action_book_appointment_submit"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        user_msg = tracker.latest_message.get('text')
        print(tracker.get_slot("consulttype"))
        buttons=[]
        message=Get_Doctors(tracker.get_slot("id"),tracker.get_slot("consulttype"))
        print(message)
        for word in message.split(','):
            button = {'title': word, 'payload': word}
            buttons.append(button)
        text = tracker.latest_message.get("text")
        dispatcher.utter_message(text="Your top 5 previous doctors are:",buttons=buttons)                
        return []

This has to be implemented in a new custom action after this action

Yes you are Right but without the user selection of the buttons it is moving to another action within 3 seconds

What do you mean by “within 3 seconds”?

It was moving to next action without the user selection of button class ActionidSubmit(Action):

def name(self) -> Text:
    return "action_book_appointment_submit"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    user_msg = tracker.latest_message.get('text')
    print(tracker.get_slot("consulttype"))
    buttons=[]
    message=Get_Doctors(tracker.get_slot("id"),tracker.get_slot("consulttype"))
    print(message)
    for word in message.split(','):
        button = {'title': word, 'payload': word}
        buttons.append(button)
    dispatcher.utter_message(text="Your top 5 previous doctors are:",buttons=buttons)                
    return [FollowupAction("action_name")]

class ActionTimeSubmit(Action):

def name(self) -> Text:

    return "action_time_submit"

def run(self, dispatcher: CollectingDispatcher,

        tracker: Tracker,

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

    text = tracker.latest_message.get("text")
    print(text)

    dispatcher.utter_message(text="Thank you")

    return []