Is their any example for slot value boolean


(Nikhil Bansal) #1


I am extracting a validation string in which i am extracting value to be “valid” or “not valid”. But i want my slot to show true or false for the above cases. Is their a way i can achieve that?

(Akela Drissner) #2

Check this in a custom action and use the boolean slot

(Yogesh Kothiya) #3

Have slot defined as below,


        type: bool

In custom action i.e

If (extracted_value == "valid"):
    validation_status = True
elsif (extracted_value == "not valid"): 
    validation_status = False
return [SlotSet("validation_string", validation_status )]

(Nikhil Bansal) #4

i followed your approach but slot value is picking up "valid & “not valid” instead of true and false

(Yogesh Kothiya) #5

Please try this.

Assume your slot and entity name is “validation_status”, intent name is “valid” and “not_valid” domain.yml:

        type: bool

In custom action return slot value i.e

def submit(self, dispatcher, tracker, domain):    
    validation_status  = tracker.get_slot("validation_status")
    return [SlotSet("validation_status ", validation_status )]

Story 1

  • valid
    • slot{"validation_status ": true}
    • utter_***

Story 2

  • not_valid
    • slot{"validation_status ": false}
    • utter_***

Let me know if this works.

(Nikhil Bansal) #6

what is the use of slot type if i have to write true and false?

(Yogesh Kothiya) #7

As per rasa nlu document on slot. It is used as bot memory to influence the dialogue. If you just want to store some data, but don’t want it to affect the flow of the conversation, use an unfeaturized slot.

(Nikhil Bansal) #8

will this unfeaturized slot type store hard code string also? like if we mention a random string from action itself?