Hello community. Since a few days I’m crashing on a problem. I would like to execute a custom action based on the value of a slot. For example if the slot is “1”, I execute the action “action_one”, but if the slot is “2”, I execute “action_two”. I would also like these actions to be taken into account in the rules and stories.
Hello!
Try the code below. Note that you must define my_slot
as categorical
in domain file
stories:
- story: run on my_slot=1
steps:
- intent: execute_action
- slot_was_set:
- my_slot: "2"
- action: action_one
- story: run on my_slot=2
steps:
- intent: execute_action
- slot_was_set:
- my_slot: "1"
- action: action_two
Have a look here to learn more:
Thanks for the help. It worked
1 Like
Hello, i still encounter a problem that the system can’t recognize the numerical input. It does not give any output whenever i give the input. here is my story.yml:
-
story: start chatbot 1 steps:
- intent: greet
- action: utter_ask_user_question
- action: utter_ask_menu
- intent: menu
- slot_was_set:
- option: 1
- action: utter_iamabot
-
story: start chatbot 2 steps:
- intent: greet
- action: utter_ask_user_question
- action: utter_ask_menu
- intent: menu
- slot_was_set:
- option: 2
- action: utter_welcome_menu_tk
my domain.yml: slots: option: type: categorical values: - 1 - 2 mappings: - type: custom
my nlu.yml
- intent: menu
examples: |
- (1)[option]
- (2)[option]
any help?