Slot not set from button

Below is my domain, story and action data. I am trying to set a slot using buttons but I’m not able to do it. It is always “None”

domain.yml

slots:
  medicationReason:
    type: text
    initial_value: "None"

- text: "Choose from following options"
    buttons:
    - title: "I am having side effect"
      payload: '/medicationReasonChoose{"medicationReason": "sideEffect"}'
    - title: "I need help with pharmacies"
      payload: '/medicationReasonChoose{"medicationReason": "pharmacy"}'

stories.md

    ## story_medicationReasonChoose
    * medicationReasonChoose
     - slot{"medicationReason": "sideEffect"}
     - action_medication_reason_form

actions.py

class ActionMedicationReasonForm(Action):
    def name(self):
       # type: () -> Text
       return "action_medication_reason_form"

    @staticmethod
    def required_slots(tracker):
        # type: () -> List[Text]

        return ["medicationReason"]

    def run(self, dispatcher, tracker, domain):
        # type: (CollectingDispatcher, Tracker, Dict[Text, Any]) -> List[Dict]
        print(tracker.slots)
        dispatcher.utter_message("slot_values")
        return []

console {u'date': None, u'medicationReason': u'None', u'requested_slot': None, u'name': None}

Try to put {"medicationReason": "pharmacy"}' next to your intent in your stories, like that :

## story_medicationReasonChoose
* medicationReasonChoose
 - slot{"medicationReason": "sideEffect"}
 - action_medication_reason_form

I tried that too. But no luck.

* medicationReasonChoose{"medicationReason": "sideEffect"}

{u'date': None, u'medicationReason': u'None', u'requested_slot': None, u'name': None}

@apurva Can you give some suggestions, please?

@kxr123330 @huberrom 's suggestion is what i would try with multiple stories

* medicationReasonChoose{"medicationReason": "sideEffect"}
 - slot{"medicationReason": "sideEffect"}

create multiple stories this way, train and see what you get. Other possibility is issues with intent classification, but let’s first try with story modification and see how it goes. Do you see the correct intent when you pass back the button value from front end? You can try the same thing with ‘inform’ intent and see what you get.

It is hitting the correct action but the slot values are always None. I tried creating multiple stories and is still None.

@ksr123330 in the logs/console do you see that the correct intent is identified? You might want to run this in debug mode or try out in interactive mode to see intent classification.

1 Like

Yes. Correct intent is identified.

This is my action

class ActionMedicationReasonForm(Action):
    def name(self):
       # type: () -> Text
       return "action_medication_reason_form"

    @staticmethod
    def required_slots(tracker):
        # type: () -> List[Text]

        return ["medicationReason"]

    def run(self, dispatcher, tracker, domain):
        # type: (CollectingDispatcher, Tracker, Dict[Text, Any]) -> List[Dict]
        print(tracker.get_slot("medicationReason"))
        dispatcher.utter_message("slot_values")
        return []

And this is what I see in console

DEBUG:rasa_core_sdk.executor:Received request to run 'action_medication_reason_form'
None
DEBUG:rasa_core_sdk.executor:Successfully ran 'action_medication_reason_form'
127.0.0.1 - - [2019-02-19 14:15:23] "POST /webhook HTTP/1.1" 200 191 0.004031

@kxr123330 can you run this interactive mode and post the output(s) you get.

1 Like

It is getting the correct slot in interaction mode. Why is it not working when I access it from client?

1 Like

@kxr123330 based on what you said above your intent should have been

medicationReasonChoose

and medicationReason is an entity

I may be wrong here but that is what it seems based on the information you have provided.

1 Like

I’m sorry, I renamed it to medicationReason. Even with medicationReasonChoose in interactive mode, it is filling the slots.

This is how I run:

python -m rasa_nlu.train -c nlu_config.yml --data data/nlu_data.md -o models --fixed_model_name nlu --project current --verbose
python -m rasa_core.train -d domain.yml -s data/stories.md -o models/current/dialogue -c policies.yml
python -m rasa_core_sdk.endpoint --actions actions
python -m rasa_core.run --enable_api -d models/current/dialogue -u models/current/nlu  --port 5005 --credentials credentials.yml --cors "*"

Is anything wrong with this?

@kxr123330 seems you have not created endpoints.yml but since your custom action classes are been invoked it should be using default endpoint which is fine (more details here) . Your commands look okay to me. You might want to run action server in --debug and/or --verbose mode and see whats going on. If it is working in interactive mode then only other possibility is your front end is not sending the value correctly to rasa. How are you testing it? try any rest client and see how it behaves.

1 Like

Thanks @apurva. You were right. It was because of my client side. Now slots are getting filled. Thanks so much.

@apurva can you help me with the same kind of issue, i will post all the files, and also can you tell me how to define the intent? my Story:

  • incident
    • utter_impactchoose
  • impact{“impact_entity”:“1- Extensive/Widespread”}
    • slot{“impact_entity” : “1- Extensive/Widespread”}
    • action_impactjsonload

my NLU Intent:

intent:impact

my domain file: slots: impact_entity: type: text

entities:

  • person_id

  • impact_entity

    utter_impactchoose:

    • text: “Sure! Please help me with few of the details! Choose the impact from the following” buttons:
      • title: “1- Extensive/Widespread” payload: ‘/impact{“impact_entity”: “1- Extensive/Widespread”}’
      • title: “2-Significant/Large” payload: ‘/impact{“impact_entity”: “2-Significant/Large”}’
      • title: “3- Moderate/Medium” payload: ‘/impact{“impact_entity”: “3- Moderate/Medium”}’
      • title: “4- Minor/Localized” payload: ‘/impact{“impact_entity”: “4- Minor/Localized”}’

my custom code: class Jsonload(Action):

def name(self):
	return "action_impactjsonload"
	
def run(self, dispatcher, tracker, domain):
	impact_entity = tracker.get_slot('impact_entity')
	a= str(impact_entity)

b=“1- Extensive/Widespread”

	f = {"impact": a}
	
	with open('data.txt', 'w') as outfile:
		json.dumps((f, outfile))
	return []

Can you please help me on this.

Regards, Pausali

I am also facing a similar issue. The slot value is not being set even though I am passing it correctly from my custom action.

My story is as follows

story_02

  • intent_2{“test_slot”: “Some value”}
    • slot{“test_slot”: “Some value”}
    • action_03

intent_2 is getting invoked from an action through button click in this way

buttons = []
message_title = "Some message"
slot_json_str = json.dumps({"test_slot":"Abrakadabra"})
buttons.append(
	{
		"title": "Abrakadabra",
		"payload": "/{}{}".format(_intent_name, slot_json_str),                  
	})
slot_json_str = json.dumps({"test_slot":"HokasPhokas"})
buttons.append(
	{
		"title": "HokasPhokas",
		"payload": "/{}{}".format(_intent_name, slot_json_str),
	})  
dispatcher.utter_button_message(message_title, buttons=buttons)
return []

I was expecting that test_slot would be getting set, but it is not. Am I doing something wrong here ? I need the value of test_slot inside action_03. I get None instead.

Can you please tell me how you fixed the issue.I am getting the same issue, the bot works fine when i run through cmd prompt using shell or interative command but when i integrate it to a web page on my local machine the button slots are not getting filled, but the other slots are . I am getting a none type error as i am doing validation on the slot value

Thank you.