How to call different story based on slot value status

Hi All,

I am trying to execute different flow or story in my project based on whether the value of slot is filled or not. How can achieve. Right now I am trying but it’s not working.

Below is my story file code snippet:

## leave apply1
* leav_apply
    - action_check_logged_for_leave_apply

## leave apply2
* leav_apply{"emp_code":"OMI-1023","password":"Omfys@345"}
    - slot{"emp_code":"OMI-1023","password":"Omfys@345"}
    - utter_for_no_of_days

Based on above story format if slot value is not filled it should go to first flow else move on to second flow. But it’s going for first flow or first story always. Why is that happening can anybody elaborate on that.

1 Like

Hi @prashant_kamble Could you please post your domain and nlu files? Also, I think you need at least two intents for the intent classifier to be active.

Hi @j.mosig,

I eventually able to solve it using bool slot datatype. Based on true-false values now I am able to change the story flow. But thanks for your reply. :blush::blush:

Below is my story and custom action code snippet :

story.md (code snippet):

leave apply1

  • leav_apply
    • action_check_login_status
    • slot{“login_status”:true}
    • utter_for_no_of_days
    • action_get_leave_balance
    • utter_leave_option

leave apply3

  • leav_apply
    • action_check_login_status
    • slot{“login_status”:false}
    • utter_service_failed_login_message

actions.py (code snippet):

class ActionCheckLoginStatus(Action):
	def name(self):
		return 'action_check_login_status'
		
	def run(self, dispatcher, tracker, domain):
		emp_code = tracker.get_slot('emp_code')
		password = tracker.get_slot('password')
		print("employee code is",emp_code)
		print("password is",password)

		intent =  tracker.latest_message['intent'].get('name')

		login_stauts = False
		

		if emp_code is None or password is None:
			return [SlotSet('login_status',False)]
		else:
			return [SlotSet('login_status',True)]



		return []

This is how I achieved :slightly_smiling_face:

3 Likes

I am facing similar situation and might go with your approach. Additional question, what if you want to set all of your slots from previous conversations when ever a session start, not all slot value may come from the conversation though.