Is their any example for slot value boolean

Hi,

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?

1 Like

Check this in a custom action and use the boolean slot

Have slot defined as below,

domain.yml:

slots:
   validation_string:
        type: bool

In custom action i.e actions.py:

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

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

Please try this.

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

slots:
   validation_status:
        type: bool

In custom action return slot value i.e actions.py:

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

Stories.md

Story 1

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

Story 2

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

Let me know if this works.

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

1 Like

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.

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