# Slots Set By Clicking Buttons

**URL:** <https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629>\
**Category:** Rasa Open Source\
**Created:** [April 17, 2020, 1:10am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629 "2020-04-17T01:10:37Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![petitbonzai31](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/petitbonzai31/32/1790_2.png) [@petitbonzai31](https://forum.rasa.com/u/petitbonzai31)\
**Post date:** [April 12, 2021, 10:08am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/22 "2021-04-12T10:08:15Z")

</div>

Hello, I’ve tried this : /intent{{“entities”:“entity value”}} to specify an intent with a given entity value. I wanted to know if it is possible to add several entities values like :

/intent{{“entities1”:“entity value”},{“entities2”:“entity value”}}

Thanks

---

<div class="post-metadata">

**Author:** ![YuaNWA](https://avatars.discourse-cdn.com/v4/letter/y/ce73a5/32.png) [@YuaNWA](https://forum.rasa.com/u/YuaNWA)\
**Post date:** [April 13, 2021, 6:09am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/23 "2021-04-13T06:09:46Z")

</div>

You should be able to do it like this

```
/intent{{“entities1”:“entity value”, “entities2”:“entity value”}}
```

---

<div class="post-metadata">

**Author:** ![Chatbot\_Ra](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chatbot_ra/32/2238_2.png) [@Chatbot\_Ra](https://forum.rasa.com/u/Chatbot_Ra)\
**Post date:** [April 27, 2021, 10:52am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/24 "2021-04-27T10:52:38Z")

</div>

Sorry, why does my solution not work:

domain.yml:

```auto
slots:
  datenschutzhinweis:
    type: text

  utter_askIfCustomerHappy:
  - text: "Are you happy with the product?"
    buttons:
    - title: "Yes, happy"
      payload: /affirm{{"customer_satisfaction":"yes"}}      
    - title: "No, unhappy"
      payload: 'denny{{"customer_satisfaction":"no"}}

  utter_satisfaction:
    - text: "Thanks for your answer. You are {customer_satisfaction}!"

```

stories.yml

```auto
stories:

- story: happy path
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_askIfCustomerHappy
  - intent: affirm
  - action: utter_satisfaction

```

If I go the happy path, the response is: `*Thanks for your answer. You are None!*`

---

<div class="post-metadata">

**Author:** ![snek](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/snek/32/13510_2.png) [@snek](https://forum.rasa.com/u/snek)\
**Post date:** [April 28, 2021, 1:22pm UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/25 "2021-04-28T13:22:41Z")

</div>

> [@Chatbot\_Ra](#):
>
> `'denny{{"customer_satisfaction":"no"}}`

Is that apostrophe meant to be a “/”?

---

<div class="post-metadata">

**Author:** ![YuaNWA](https://avatars.discourse-cdn.com/v4/letter/y/ce73a5/32.png) [@YuaNWA](https://forum.rasa.com/u/YuaNWA)\
**Post date:** [April 29, 2021, 3:27am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/26 "2021-04-29T03:27:32Z")

</div>

Did you define your slot for customer\_satisfaction? Is the influence\_conversation = true for it? If influence\_conversation is set to true, then you need to change your story to

```
- intent: affirm
- slot_was_set:
    - customer_satisfaction: yes
- action: utter_satisfaction

```

There is also the typo for

```
payload: 'denny{{"customer_satisfaction":"no"}}

```

It should probably be

```
 payload: /deny{{"customer_satisfaction":"no"}}
```

---

<div class="post-metadata">

**Author:** ![Sandares](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Sandares](https://forum.rasa.com/u/Sandares)\
**Post date:** [September 6, 2021, 7:07am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/27 "2021-09-06T07:07:18Z")

</div>

Hi @Johan1us,   
I also faced such a problem. In my use case the number of buttons are dynamic. The titles for the buttons are taken by a database in custom actions. Then I want to handle all these dynamic buttons using one intent and I want to implement these buttons using custom actions. But when I add the payload like above example without double quote it gives me errors. ex: when I put `/feedback_button{{"feedback_value":"positive"}}` in custom action it gives me syntax errors.  
 This is a sample code for get you some idea about my issue. This code is is `actions.py`

> send\_button = [{“title”: “title 1”, “payload”: /sample{{“entity1”:“entity\_value\_1”}}, {“title”: “title 2”, “payload”: /sample{{“entity1”:“entity\_value\_2”}}}]  
> dispatcher.utter\_button\_message(text=“The buttons are”,buttons=send\_button)

I want after someone click the relevant button it should be identify the intent `sample` and fill the entity with relevant entity value. ex: if user select button 1 named `title 1` I want to find the intent sample and fill the `entity1` with `entity_value_1`

how can I fix this?

---

<div class="post-metadata">

**Author:** ![gourav1212](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/gourav1212/32/19495_2.png) [@gourav1212](https://forum.rasa.com/u/gourav1212)\
**Post date:** [November 8, 2021, 4:45pm UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/28 "2021-11-08T16:45:35Z")

</div>

@akelad , can you reply to this Question here by Sandares .

Also, How should I capture what the user has clicked , if the slot value are dynamic. as when I click on the button it gives me the intent name instead of the button title value.

Thanks.

---

<div class="post-metadata">

**Author:** ![realmadrid0123](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@realmadrid0123](https://forum.rasa.com/u/realmadrid0123)\
**Post date:** [November 12, 2021, 11:23pm UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/29 "2021-11-12T23:23:23Z")

</div>

Hi @pandaxar

can you put the code of how did you created buttons widgets in case the response contains buttons with flutter ?

Thank you

---

<div class="post-metadata">

**Author:** ![jona](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jona/32/15059_2.png) [@jona](https://forum.rasa.com/u/jona)\
**Post date:** [December 23, 2021, 2:41am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/30 "2021-12-23T02:41:58Z")

</div>

Hello, Do you know how can I set a slot of type list using an action server? I am trying to create a checklist functionality I have the frontend ready but I am stuck on how to set the slot. This is a sample code. The idea is when the button is pressed it sets a slot of type List (a list of strings). I am using Rasa 3.0.3. I used the same on 2.8.16 and it works. I would really appreciate your help.

action.py

```auto
class ActionAskFeelings(Action):

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

    async def run(self,
                  dispatcher: CollectingDispatcher,
                  tracker: Tracker,
                  domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        app_dict = {
            'products': ['happy', 'great']
        }
        app_json = json.dumps(app_dict)
        dispatcher.utter_message(
            text='How do you feel',
            buttons=[
                {
                    "title": "great",
                    "type": "postback",
                    "payload": "/tell_hello_world{}".format(app_json),
                },
                {
                    "title": "super sad",
                    "type": "postback",
                    "payload": "/mood_sad",
                }
            ]
        )
        # dispatcher.utter_message(attachment=MOCK_SCHEMA)
        return []

```

I defined the slot in this way on domain.yml

```auto
slots:
  products:
    type: list
    mappings:
      - type: custom

```

This is the warning message I got

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/3X/6/c/6cb30b952e4ba28b7ca3fef3eae4da5cdff110fa.png)

I created an action to print the slot value after press the button, but it is always empty

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/3X/8/d/8dabd2b5d2970d806418f69641bf5919b7f09859.png)

---

<div class="post-metadata">

**Author:** ![rajas.black](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rajas.black/32/15711_2.png) [@rajas.black](https://forum.rasa.com/u/rajas.black)\
**Post date:** [December 24, 2021, 6:13am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/31 "2021-12-24T06:13:53Z")

</div>

Hi @jona,

Try with this code once:

```auto
buttons=[]
            buttons.append({'title': 'Great', 'payload': '/tell_hello_world{"Products": "Great"}'})
            buttons.append({'title': 'Happy', 'payload': '/tell_hello_world{"Products": "Happy"}'})
            buttons.append({'title': 'Super Sad', 'payload': '/mood_sad'})
            dispatcher.utter_message(text="How do you feel:\n",buttons=buttons)
            return []

```

---

<div class="post-metadata">

**Author:** ![jona](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jona/32/15059_2.png) [@jona](https://forum.rasa.com/u/jona)\
**Post date:** [December 24, 2021, 3:59pm UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/32 "2021-12-24T15:59:09Z")

</div>

Thanks, @rajas.black buttons works also I was able to make work my last approach on Rasa 3 changing domain.yml in this way

```auto
entities:
  - product
  - products

slots:
  products:
    type: list
    influence_conversation: true
    mappings:
      - type: from_entity
        entity: products

  product:
    type: text
    influence_conversation: true
    mappings:
      - type: from_entity
        entity: product

```

Using Rasa 2.8.16

```auto
slots:
  products:
    type: list

  product:
    type: text

```

---

<div class="post-metadata">

**Author:** ![rajas.black](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rajas.black/32/15711_2.png) [@rajas.black](https://forum.rasa.com/u/rajas.black)\
**Post date:** [January 12, 2022, 8:33am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/33 "2022-01-12T08:33:16Z")

</div>

@jona Glad it worked. Please mark it as answer and close the thread.

---

<div class="post-metadata">

**Author:** ![webdev-rohit](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/webdev-rohit/32/18943_2.png) [@webdev-rohit](https://forum.rasa.com/u/webdev-rohit)\
**Post date:** [March 2, 2022, 7:06pm UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/34 "2022-03-02T19:06:40Z")

</div>

Hi @Sandares I too am getting syntax errors when I tried to do it like this. What was the solution that you found?

---

<div class="post-metadata">

**Author:** ![rajas.black](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rajas.black/32/15711_2.png) [@rajas.black](https://forum.rasa.com/u/rajas.black)\
**Post date:** [May 13, 2022, 7:09am UTC](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629/35 "2022-05-13T07:09:15Z")

</div>

Please shape the modified code, if it’s unresolved still.

[Previous page](https://forum.rasa.com/t/slots-set-by-clicking-buttons/27629.md?page=1)
