Hi, I’m quite new to Rasa and sadly haven’t figured out how to fill out slots in a form properly. Basically I have one form which loops through 2 questions or slots, which have both have same response options. Both slots save their values from the same intents. When the chatbot gets to the first slot of the form, then the right intent value will be saved. But unfortunately it automatically also saves this same intent value in the second slot. How can I go through the form and save the values in the slots independently?
domain.yml
version: "3.1"
intents:
- greet
- goodbye
- affirm
- deny
- request_initial_phq
- none_days
- few_days
- several_days
- most_days
entities:
- disinterest
- hopelessness
slots:
disinterest:
type: float
influence_conversation: false
mappings:
- type: from_intent
intent: none_days
value: 0.00
# only listens to entity when form is active
conditions:
- active_loop: initial_phq_form
- type: from_intent
intent: few_days
value: 1.00
# only listens to entity when form is active
conditions:
- active_loop: initial_phq_form
- type: from_intent
intent: several_days
value: 2.00
# only listens to entity when form is active
conditions:
- active_loop: initial_phq_form
- type: from_intent
intent: most_days
value: 3.00
# only listens to entity when form is active
conditions:
- active_loop: initial_phq_form
hopelessness:
type: float
influence_conversation: false
mappings:
- type: from_intent
intent: none_days
value: 0.00
# only listens to entity when form is active
conditions:
- active_loop: initial_phq_form
- type: from_intent
intent: few_days
value: 1.00
# only listens to entity when form is active
conditions:
- active_loop: initial_phq_form
- type: from_intent
intent: several_days
value: 2.00
# only listens to entity when form is active
conditions:
- active_loop: initial_phq_form
- type: from_intent
intent: most_days
value: 3.00
# only listens to entity when form is active
conditions:
- active_loop: initial_phq_form
forms:
initial_phq_form:
required_slots:
- disinterest
- hopelessness
responses:
utter_start_initial_form:
- text: Please answer all questions in number of days. Let's start!
utter_ask_disinterest:
- text: How frequently were you impacted by having little interest or less enjoyment in your activities over the past two weeks?
utter_ask_hopelessness:
- text: Did you feel down or hopeless over the past two weeks?
actions:
- initial_phq_form
nlu.yml
version: "3.1"
nlu:
- intent: none_days
examples: |
- [0](disinterest)
- regex: few_days
examples: |
- ^[1-6]$
# 7-11
- regex: several_days
examples: |
- ^([7-9]|1[0-1])$
# 11-14
- regex: most_days
examples: |
- ^(1|1[2-4])$
- intent: few_days
examples: |
- [2](disinterest)
- [2](hopelessness)
- intent: several_days
examples: |
- [8](disinterest)
- [9](hopelessness)
- intent: most_days
examples: |
- [8](disinterest)
- [9](hopelessness)
- intent: request_initial_phq
examples: |
- i like to start now
- i want to start
- can i do the first questionnaire
- can i start
- i like to move on
- intent: affirm
examples: |
- yes
- y
- indeed
- of course
- that sounds good
- correct
rules.yml
version: "3.1"
rules:
# rule how start form
- rule: Activate initial form
steps:
- intent: request_initial_form
- action: inital_phq_form
- active_loop: initial_phq_form
# rule how stop form
- rule: Submit form
condition:
- active_loop: initial_phq_form
steps:
- action: initial_phq_form
# when form is complete, loop automatically sets to null
- active_loop: null
- slot_was_set:
- requested_slot: null
stories.yml
version: "3.1"
stories:
- story: user starts initial form
steps:
- intent: request_initial_phq
- action: utter_start_initial_form
- intent: affirm
- action: initial_phq_form
- active_loop: initial_phq_form