I have created the following simple bot to test how SlotSet works.
YAML files:
version: "3.0"
nlu:
- intent: opening
examples: |
- Hi
- Hello
- intent: closing
examples: |
- Goodbye
- Farewell
rules:
- rule: opening rule
steps:
- intent: opening
- action: utter_slot_value
- action: utter_greeting
- action: action_set_my_slot_value
- action: utter_slot_value
intents:
- opening
slots:
my_slot:
type: categorical
initial_value: init
values:
- init
- modified
influence_conversation: true
mappings:
- type: custom
responses:
utter_greeting:
- text: "Hello!"
utter_slot_value:
- text: "Value of my_slot: {my_slot}"
actions:
- action_set_my_slot_value
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
actions.py file:
from typing import Any, Text, Dict, List, Union
from rasa_sdk import Action, Tracker
from rasa_sdk.events import SlotSet, AllSlotsReset
from rasa_sdk.executor import CollectingDispatcher
class ActionSetMySlotValue(Action):
def name(self) -> Text:
return "action_set_my_slot_value"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
dispatcher.utter_message(text="Setting my_slot value")
return [SlotSet("my_slot", "modified")]
I have executed it in rasa shell and obtained the following result:
Your input -> hi
Value of my_slot: init
Hello!
Setting my_slot value
Your input -> hi
Value of my_slot: init
Hello!
Setting my_slot value
Your input ->
The execution of the rule is aborted (the value of my_slot does not change and the step of the rule is not executed).
My question is: why such a thing happens?!
After changing the type of my_slot to bool the result is analogical:
Your input -> hi
Value of my_slot: False
Hello!
Setting my_slot value
Your input -> hi
Value of my_slot: False
Hello!
Setting my_slot value
Your input ->
However, when I change the type of my_slot to text, the result is following:
Your input -> hi
Value of my_slot: init
Hello!
Setting my_slot value
Value of my_slot: modified
Your input -> hi
Value of my_slot: modified
Hello!
Setting my_slot value
Value of my_slot: modified
Your input ->