Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slot Setting and Filling from Button #2525

Closed
asaiyed10 opened this issue Sep 19, 2018 · 9 comments
Closed

Slot Setting and Filling from Button #2525

asaiyed10 opened this issue Sep 19, 2018 · 9 comments

Comments

@asaiyed10
Copy link

Rasa Core version:
11.3
Python version: 2.7

Operating system (windows, osx, ...):
ox
Issue:

These buttons that are not setting slots when selected by the user.

I think im using the correct / intent { entitiy : } relationship, maybe I'm missing something obvious? My slot and entities are named the same....
The code is below. I would like the slot to set the type of cough selected by the user

domain.yml

slots:
  cough:
    type: text
    initial_value: "empty"

intents: 
  - symptoms_cough_wheezing
  - symptoms_cough_difficult

entities:
  - cough


templates: 

     utter_cough:
      - text: "You seem to be experiencing a cough. Please select the best description"
        buttons:
          - title: I am experiencing wheezing
            payload: '/symptoms_cough_wheezing{"cough":"wheezing"}'

          - title: Are you having shortness of breath? 
            payload: '/symptoms_cough_difficult{"cough":"shortness of breath"}'
##cough 1
* symptoms_cough
  - utter_cough
* symptoms_cough_wheezing{"cough": "wheezing"}
  - slot{"cough": "wheezing"}
  - action_1

##cough 2
* symptoms_cough
  - utter_cough
* symptoms_cough_wheezing{"cough": "difficult"}
  - slot{"cough": "difficult"}
  - action_2
@akelad
Copy link
Contributor

akelad commented Sep 20, 2018

This should be setting the slots, yes. Could you post the debug log of where the'yre not getting set?

@asaiyed10
Copy link
Author

asaiyed10 commented Sep 20, 2018

2018-09-19 20:17:20 DEBUG    rasa_core.processor  - Bot utterance 'BotUttered(text: You seem to be experiencing a cough. Please select the best description, data: {
  "buttons": [
    {
      "payload": "/symptoms_cough_wheezing{\"cough\":\"wheezing\"}", 
      "title": "wheezing"
    }, 
    {
      "payload": "/symptoms_cough_difficult{\"cough\":\"difficult\"}", 
      "title": "difficult"
    }
  ], 
  "elements": null, 
  "attachment": null
})'
2018-09-19 20:17:20 DEBUG    urllib3.connectionpool  - http://localhost:5005 "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 None
2018-09-19 20:17:20 DEBUG    rasa_core.policies.memoization  - Current tracker state {[....]}
You seem to be experiencing a cough. Please select the best description
1: wheezing (/symptoms_cough_wheezing{"cough":"wheezing"})
2018-09-19 20:17:20 DEBUG    rasa_core.policies.memoization  - There is no memorised next action
2: difficult (/symptoms_cough_difficult{"cough":"difficult"})
2018-09-19 20:17:20 DEBUG    rasa_core.policies.ensemble  - Predicted next action using policy_2_KerasPolicy
2018-09-19 20:17:20 DEBUG    rasa_core.processor  - Predicted next action 'action_listen' with prob 1.00.
2018-09-19 20:17:20 DEBUG    rasa_core.processor  - Action 'action_listen' ended with events '[]'
127.0.0.1 - - [2018-09-19 20:17:20] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 697 0.020078
2
2018-09-19 20:17:24 DEBUG    urllib3.connectionpool  - Starting new HTTP connection (1): localhost:5005
2018-09-19 20:17:24 DEBUG    rasa_core.tracker_store  - Recreating tracker for id 'default'
2018-09-19 20:17:24 DEBUG    rasa_core.processor  - Received user message '4' with intent '{u'confidence': 0.9042121767997742, u'name': u'user_phoneNumber'}' and entities '[]'
2018-09-19 20:17:24 DEBUG    rasa_core.processor  - Logged UserUtterance - tracker now has 20 events
2018-09-19 20:17:24 DEBUG    rasa_core.processor  - Current slot values: 
	cough: None

@asaiyed10
Copy link
Author

Sorry, maybe I meant filling slots?

I want the value to be stored in slot "cough"

@asaiyed10 asaiyed10 changed the title Slot Setting from Button Slot Setting and Filling from Button Sep 20, 2018
@akelad
Copy link
Contributor

akelad commented Sep 21, 2018

ahhh the problem is you're typing "2", on the command line you have to copy the payload and send that as the message. Please try that and let me know if it works!

@naoko
Copy link
Contributor

naoko commented Sep 24, 2018

Yes as per @akelad , literally, you want to type /symptoms_cough_difficult{"cough":"shortness of breath"}

@akelad
Copy link
Contributor

akelad commented Sep 24, 2018

@asaiyed10 does that solve your problem?

@asaiyed10
Copy link
Author

Sorry for the late reply, and thank you for your help! It worked

@tmbo tmbo transferred this issue from RasaHQ/rasa_core Mar 21, 2019
@ravitejakammela
Copy link

I have a button with the title "Low". Whenever a user clicks this button I want this title("Low") should be set as the slot value. This particular button is mapped to an intent "incident". The slot name is "priority". Can anyone suggest to me how to achieve this?

@jonra1993
Copy link

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

image

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

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants