Slots Set By Clicking Buttons

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

You should be able to do it like this

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

Sorry, why does my solution not work:

domain.yml:

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

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!*

Is that apostrophe meant to be a “/”?

1 Like

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"}}
1 Like

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?

@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.

Hi @pandaxar

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

Thank you

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

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

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

This is the warning message I got

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

Hi @jona,

Try with this code once:

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 [ ]
1 Like

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

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

slots:
  products:
    type: list

  product:
    type: text

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

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

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