Values not coming from tracker.get_slot from payload in button

I want to get values from payload in button and use it in my custom action but value not coming

My domain file is below

responses:
      utter_ask_budget:
      - text: Which average budget segment for two people looking for?
        buttons:
        - title: Lesser than Rs. 300
          payload: Lesser than Rs. 300
        - title: Rs. 300 to 700
          payload: Rs. 300 to 700
        - title: More than 700
          payload: More than 700

Action file is below

class ActionCheckBudget(Action):
	def name(self):
		return "action_check_budget"
	
	def run(self, dispatcher, tracker, domain):
		cost_replied = tracker.get_slot('budget')
		
		#dispatcher.utter_message(cost_replied) 
		if cost_replied == 'Lesser than Rs. 300':
			return[SlotSet('budget', 'lesser')]
		elif cost_replied == 'Rs. 300 to 700':
			return[SlotSet('budget', 'between')]
		elif cost_replied == 'More than 700':
			return[SlotSet('budget', 'higher')]
		else:
			return[SlotSet('budget', '')]

Some of my stories are below:

## complete path 3 - location specified initially
* greet
    - utter_greet
* restaurant_search{"location": "Kolkata"}
    - slot{"location": "Kolkata"}
    - action_check_location
    - slot{"location": "Kolkata"}
    - utter_ask_cuisine
* restaurant_search{"cuisine": "Chinese"}
    - slot{"cuisine": "Chinese"}
    - action_check_cuisine
    - slot{"cuisine": "Chinese"}
    - utter_ask_budget
* restaurant_search{"budget": "Rs. 300 to 700"}
    - slot{"budget": "Rs. 300 to 700"}
    - action_check_budget
    - slot{"budget": "between"}
    - utter_top_5_restaurant
    - action_search_restaurants
    - slot{"budget": "between"}
    - utter_ask_to_email
* affirm
    - utter_ask_email_id
* send_email{"email":"sid321axn@hotmail.com"}
    - slot{"email":"sid321axn@hotmail.com"}
    - action_check_email
    - slot{"email":"sid321axn@hotmail.com"}
    - action_send_email
    - slot{"email":"sid321axn@hotmail.com"}
    - utter_goodbye
    - action_restarted

In this case slot of budget is not coming it is null

cost_replied = int(tracker.get_slot('budget'))

1 Like

This will throw a ValueError.

If you specify the payload like this, its exactly the same as if a user would type that text. However, your NLU component will most likely not be able to pick this up as an entity to map it to a slot.

Your payloads should look like

/answer_budget {"budget": "Rs. 300 to 700"}

Its explained here

Thanks the problem is solved. many many thanks for the response

1 Like