Retrieval intents for two categories of people

Hello @nik202 ,

Please help me here, I am having this issue: my idea is this.

I have questions and answers for two types of people

Doctors:

  • the replies for these people are more complex

NotDoctors

  • the replies are simple and for normal people

I want to build the bot in such a way that it asks with two buttons, if you are a doctor then it shows the complex answers, if you are not a doctor, it shows simple faq answers.

This is how I have been trying to do below. Where could I be missing it.

when I run the bot I get the error below, its not picking the answers in the right way, it seems like its guessing or something.

Error:

Bot loaded. Type a message and press enter (use '/stop' to exit): 
Your input ->  hello                                                                                                                                     
Hello, how can I help you today?
? Hey! How are you? Are you a qualified Medical Personell?  1: Yes. (doctor{"doctor":true})                                                              
Your input ->  what is covid?                                                                                                                            
2021-09-24 17:34:24 ERROR    rasa.core.actions.action  - Couldn't create message for response 'utter_notdoctor/what_is_covid'.
Your input ->  how is it spread?                                                                                                                         
2021-09-24 17:34:33 ERROR    rasa.core.actions.action  - Couldn't create message for response 'utter_doctor/covid_spread'.
Your input ->   

Rasa Version

(rasaenv) Drs-MacBook-Pro:Trial-Ground drjamesmugume$ rasa --version
Rasa Version      :         2.8.1
Minimum Compatible Version: 2.8.0
Rasa SDK Version  :         2.8.1
Rasa X Version    :         0.39.3
Python Version    :         3.7.5
Operating System  :         Darwin-19.6.0-x86_64-i386-64bit
Python Path       :         /opt/anaconda3/envs/rasaenv/bin/python
(rasaenv) Drs-MacBook-Pro:Trial-Ground drjamesmugume$ 

NLU for Doctors

version: "2.0"
nlu:
- intent: doctor/what_is_covid
  examples: |
    - what is covid
    - what's corona
    - tell me about corona virus
    - corona?
    - covid-19?
    - define corona
    - what is covid19
- intent: doctor/covid_spread
  examples: |
    - how does it spread?
    - how does covid spread.
    - does it spread by air?
    - how can one contract it?
    - what means does it spread?
    - how do people get infected?
- intent: doctor/symptoms_covid
  examples: |
    - what are the symptoms?
    - symptoms of covid?
    - is temperature a symptom?
    - what are the signs of covid?
    - covid signs and symptoms
    - what should I look out for.
    - how do I know someone has covid?
- intent: doctor/covid_vaccine
  examples: |
    - what is the cure?
    - does it have a vaccine?
    - can it be vaccinated against?
    - what vaccine should I use for covid?

NLU for non doctors

version: "2.0"
nlu:
- intent: notdoctor/what_is_covid
  examples: |
    - what is covid
    - what's corona
    - tell me about corona virus
    - corona?
    - covid-19?
    - define corona
    - what is covid19
    - what is covid?
- intent: notdoctor/covid_spread
  examples: |
    - how does it spread?
    - how does covid spread.
    - does it spread by air?
    - how can one contract it?
    - what means does it spread?
    - how do people get infected?
- intent: notdoctor/symptoms_covid
  examples: |
    - what are the symptoms?
    - symptoms of covid?
    - is temperature a symptom?
    - what are the signs of covid?
    - covid signs and symptoms
    - what should I look out for.
    - how do I know someone has covid?
- intent: notdoctor/covid_vaccine
  examples: |
    - what is the cure?
    - does it have a vaccine?
    - can it be vaccinated against?
    - what vaccine should I use for covid?

Config

# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: en

pipeline:
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
# # If you'd like to customize it, uncomment and adjust the pipeline.
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
  - name: WhitespaceTokenizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: char_wb
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 100
    constrain_similarities: true
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100
    constrain_similarities: true
  - name: ResponseSelector
    epochs: 100
    retrieval_intent: doctor
    constrain_similarities: true
  - name: ResponseSelector
    epochs: 100
    retrieval_intent: notdoctor 
    constrain_similarities: true
  - name: FallbackClassifier
    threshold: 0.35
    ambiguity_threshold: 0.1

# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies:
# No configuration for policies was provided. The following default policies were used to train your model.
# If you'd like to customize them, uncomment and adjust the policies.
# See https://rasa.com/docs/rasa/policies for more information.
  - name: MemoizationPolicy
  - name: RulePolicy
  - name: UnexpecTEDIntentPolicy
    max_history: 8
    epochs: 100
  - name: TEDPolicy
    max_history: 5
    epochs: 100
    constrain_similarities: true

Rules

version: "2.0"

rules:

- rule: Say goodbye anytime the user says goodbye
  steps:
  - intent: goodbye
  - action: utter_goodbye

- rule: Say 'I am a bot' anytime the user challenges
  steps:
  - intent: bot_challenge
  - action: utter_iamabot

- rule: ask doctor questions
  steps:
  - intent: doctor
  - action: utter_doctor

- rule: ask doctor questions
  steps:
  - intent: notdoctor
  - action: utter_notdoctor  

Domain:

version: '2.0'
session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: false
intents:
- greet
- goodbye
- notdoctor:
    is_retrieval_intent: true
- doctor:
    is_retrieval_intent: true
- stop
- inform_doctor
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
entities:
- doctor
slots:
  doctor:
    type: bool
    influence_conversation: true
responses:
  utter_greet:
  - text: Hello, how can I help you today?
  utter_ask_if_doctor:
  - buttons:
    - payload: doctor{{"doctor":true}}
      title: Yes.
    - payload: notdoctor{{"doctor":false}}
      title: No.
    text: Hey! How are you? Are you a qualified Medical Personell?
  utter_cheer_up:
  - image: https://i.imgur.com/nGF1K8f.jpg
    text: 'Here is something to cheer you up:'
  utter_did_that_help:
  - text: Did that help you?
  utter_happy:
  - text: Great, carry on!
  utter_goodbye:
  - text: Bye
  utter_iamabot:
  - text: I am a bot, powered by Rasa.
  utter_doctor/what_is_covid:
  - condition:
    - type: slot
      name: doctor
      value: true
    text: This is the answer for the doctors.
  utter_doctor/covid_spread:
  - condition:
    - type: slot
      name: doctor
      value: true
    text: Covid_spred for doctors.
  utter_doctor/symptoms_covid:
  - condition:
    - type: slot
      name: doctor
      value: true
    text: symptoms_covid for doctors.
  utter_doctor/covid_vaccine:
  - condition:
    - type: slot
      name: doctor
      value: true
    text: covid_vaccine for doctors.
  utter_notdoctor/what_is_covid:
  - condition:
    - type: slot
      name: doctor
      value: false
    text: This is the answer for the not_doctors.
  utter_notdoctor/covid_spread:
  - condition:
    - type: slot
      name: doctor
      value: false
    text: Covid_spred for not_doctors.
  utter_notdoctor/symptoms_covid:
  - condition:
    - type: slot
      name: doctor
      value: false
    text: symptoms_covid for not_doctors.
  utter_notdoctor/covid_vaccine:
  - condition:
    - type: slot
      name: doctor
      value: false
    text: covid_vaccine for not_doctors.
actions:
- utter_ask_if_doctor
- utter_doctor
- utter_goodbye
- utter_greet
- utter_notdoctor

Stories

version: "2.0"
stories:
- story: doctor path
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_ask_if_doctor
  - slot_was_set:
    - doctor: true
  - intent: doctor
  - action: utter_doctor 
  - intent: goodbye
  - action: utter_goodbye 

- story: not doctor path
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_ask_if_doctor
  - slot_was_set:
    - doctor: false
  - intent: notdoctor
  - action: utter_notdoctor
  - intent: goodbye
  - action: utter_goodbye

- story: interactive_story_1
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_ask_if_doctor
  - intent: doctor
    entities:
    - doctor: true
  - slot_was_set:
    - doctor: true
  - action: utter_doctor
  - intent: doctor
  - action: utter_doctor
  - intent: goodbye
  - action: utter_goodbye

- story: interactive_story_1
  steps:
  - intent: greet
  - action: utter_greet
  - action: utter_ask_if_doctor
  - intent: notdoctor
    entities:
    - doctor: false
  - slot_was_set:
    - doctor: false
  - action: utter_notdoctor
  - intent: notdoctor
  - action: utter_notdoctor
  - intent: notdoctor
  - action: utter_notdoctor
  - intent: goodbye
  - action: utter_goodbye

@atwine Do share all the file, I will try to see your code; if I got some time.

domain.yml (1.8 KB) config.yml (1.4 KB) stories.yml (1.6 KB) nlu.yml (203 Bytes) rules.yml (518 Bytes)

@nik202

Those are the files as requested.

@atwine give me some time please, if I got some time I will look your code.

That is fine, I am working on something else as I wait.

@nik202

any chance you have looked at the code?

@atwine share me some bot/user conversation examples, what is user input and what is the response. So that at the time of dry run I can use that example. Thanks.

@nik202 if a user chooses that they are a doctor or not doctor.

If they type a question below.

What is covid?

Then if a user is a doctor the reply will be:

This is the answer for doctors

or

This is the answer for non doctors.

@atwine can you mention bot and user infront of question and response by bot?

I hope that helps

@atwine do you have any action file too? or only those files which you send?

Yes, no action file. Maybe that is where I am making a mistake

@atwine I am seeing your code, now stay here for a while

Step1:

Step2: Selecting Yes

Step3: Selecting No

As you seeing the step3 is not returning the response which you expecting this is right? of you want to change some scenario for the same, please tell?

Your no doctor scenario is not mentioned in domain.yml? me confuse now what you want?

yes step three is not returning the right step.

I did not mention it in the domain? maybe that is my mistake. Can you help me correct that?

@atwine Mean the message should be come “This is the answer for the non-doctor” right?

Step 1 and Step 2 is fine for your use case?

Yes, step 1 and 2 okay.

Yeah the message should come: this is the answer for non-doctor

@atwine Why you using bool i.e true or false can I make the necessary changes?

@atwine What will be the questions or intents examples for non_doctors?

For me its not a feasible use case. If its a medical bot it should be doctor only what is the use of non doctor then? can you clear me your use case?

What you are looking at is an example use case: this is the real thing;

My bot is going to be answering FAQ questions about covid-19 in the Ugandan context.

My bot is going to be used by doctors and non doctors:

when a doctor asks a question (we want the bot to be able to give a more detailed scientific answer)

when a person who is not a qualified doctor asks a question (then the bot will give a simple answer.)

So the question maybe : what is covid

For the doctor: the answer is more complex in terms of science

For the non-doctor - the response is simple.

Does that make sense now?

@nik202

Please remember am new to rasa so if you see a mistake please correct it.

@atwine I can trust the content (response of the doctor) why I will trust the response of non doctor? (Personally it not make any sense?)

Q: If you are user, whom you will trust a doctor or non-doctor? you will get your answer :slight_smile:

I respect your enthusiasm of learning, that’s why I am trying my level best and trying to guide you!

@atwine Even detailed scientific answer vs complex answer vs simple answers? this again not make any sense to me :thinking:

But, I respect your use case and trying to help you!

Haha, the use case makes sense to everyone else we are working with:

Okay let me put it this way:

if i am a beginner at learning rasa and I ask you this question:

what is nlu: you will give me simple answer right?

when I am an expert at rasa and I ask: what is nlu: the answer will be different

Anyway can you assist me solve the issue, leave the use case to me.