# How to get the button Payload or Title value

**URL:** <https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788>\
**Category:** Rasa Open Source\
**Created:** [October 16, 2022, 5:23am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788 "2022-10-16T05:23:52Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 5:23am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/1 "2022-10-16T05:23:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rasa\_learner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rasa_learner/32/21721_2.png) [@rasa\_learner](https://forum.rasa.com/u/rasa_learner)\
**Post date:** [October 16, 2022, 7:27am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/2 "2022-10-16T07:27:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 7:28am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/3 "2022-10-16T07:28:28Z")

</div>

In Custom action i was displaying Buttons using API call

---

<div class="post-metadata">

**Author:** ![rasa\_learner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rasa_learner/32/21721_2.png) [@rasa\_learner](https://forum.rasa.com/u/rasa_learner)\
**Post date:** [October 16, 2022, 7:29am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/4 "2022-10-16T07:29:24Z")

</div>

Can you show the code of your current implementation?

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 7:31am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/5 "2022-10-16T07:31:37Z")

</div>

![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/3X/b/4/b400d76876b3e5ebd2a55c3ba471e6105b3c853a.png)

---

<div class="post-metadata">

**Author:** ![rasa\_learner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rasa_learner/32/21721_2.png) [@rasa\_learner](https://forum.rasa.com/u/rasa_learner)\
**Post date:** [October 16, 2022, 7:46am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/6 "2022-10-16T07:46:22Z")

</div>

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'))`

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 7:49am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/7 "2022-10-16T07:49:13Z")

</div>

Okay, i will try it

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 7:55am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/9 "2022-10-16T07:55:50Z")

</div>

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

```auto
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 []

```

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 7:58am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/10 "2022-10-16T07:58:31Z")

</div>

And in Every Api call the doctor names will be changed

---

<div class="post-metadata">

**Author:** ![rasa\_learner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rasa_learner/32/21721_2.png) [@rasa\_learner](https://forum.rasa.com/u/rasa_learner)\
**Post date:** [October 16, 2022, 8:20am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/11 "2022-10-16T08:20:14Z")

</div>

You have to change this,

> [@sai4teja3](#):
>
> `button = {'title': word, 'payload': '/'+word+'{"Dname": "' + word + '"}'}`

to,

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

```

or you can directly use,

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

```

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 8:23am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/12 "2022-10-16T08:23:14Z")

</div>

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

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/3X/1/3/137a8d77e19411fe5ee95443f662616931ad2f27.png)

if I use this how can I store the payload or title value ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/3X/5/6/56c6fa7128c5fcec86fce06ebae034fe7ca8cab0.png)

---

<div class="post-metadata">

**Author:** ![rasa\_learner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rasa_learner/32/21721_2.png) [@rasa\_learner](https://forum.rasa.com/u/rasa_learner)\
**Post date:** [October 16, 2022, 8:26am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/13 "2022-10-16T08:26:50Z")

</div>

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

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

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

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 8:29am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/14 "2022-10-16T08:29:09Z")

</div>

I followed the same but it is returning None

---

<div class="post-metadata">

**Author:** ![rasa\_learner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rasa_learner/32/21721_2.png) [@rasa\_learner](https://forum.rasa.com/u/rasa_learner)\
**Post date:** [October 16, 2022, 8:30am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/15 "2022-10-16T08:30:47Z")

</div>

Please provide your implementation

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 8:32am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/16 "2022-10-16T08:32:24Z")

</div>

```auto
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 []

```

---

<div class="post-metadata">

**Author:** ![rasa\_learner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rasa_learner/32/21721_2.png) [@rasa\_learner](https://forum.rasa.com/u/rasa_learner)\
**Post date:** [October 16, 2022, 8:40am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/17 "2022-10-16T08:40:22Z")

</div>

> [@sai4teja3](#):
>
> `text = tracker.latest_message.get("text")`

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

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 10:24am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/18 "2022-10-16T10:24:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rasa\_learner](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rasa_learner/32/21721_2.png) [@rasa\_learner](https://forum.rasa.com/u/rasa_learner)\
**Post date:** [October 16, 2022, 10:27am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/19 "2022-10-16T10:27:00Z")

</div>

What do you mean by “within 3 seconds”?

---

<div class="post-metadata">

**Author:** ![sai4teja3](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sai4teja3](https://forum.rasa.com/u/sai4teja3)\
**Post date:** [October 16, 2022, 10:34am UTC](https://forum.rasa.com/t/how-to-get-the-button-payload-or-title-value/55788/20 "2022-10-16T10:34:35Z")

</div>

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 []
```
