How to include context in intent detection?

Hi @Gur, welcome to the forum :slight_smile: . Yes you’re right, intent detection only works on the basis of the single user utterance and is run before the dialogue manager. The DM then takes the past state of the conversation and current NLU output in order to predict the next action the bot should take. (The exception to that is the currently experimental End-to-end TEDPolicy, which predicts both intents and actions, see. e.g. this forum thread).

This is a limitation in the sense that you describe, that the same answer can mean different things based on the context. In your example, the user might already respond to the first question with I have two cats, with the intent to confirm that they indeed like cats.

However, for the example conversation you posted,you could keep those as different intents:

- intent: affirm
  examples: |
    - yes
    - of course
    - sure

- intent: has_a_cat
  examples: |
    - I have a cat
    - I have two cats
    - My cat's name is Felix

and then write stories containing the different possible turns of the conversation, from which the dialogue manager can learn how different intents can appear at which point in the conversation:

- story: likes and has a cat
  steps:
  - intent: take_quiz
  - action: ask_likes_cat
  - intent: affirm
  - action: ask_has_cat
  - intent: has_cat
  - action: next_action

- story: likes and has a cat 2
  steps:
  - intent: take_quiz
  - action: ask_likes_cat
  - intent: affirm
  - action: ask_has_cat
  - intent: affirm
  - action: next_action
...

This is just one option that came to my mind from the example conversation you posted. But in general, which concrete task are you trying to solve with your bot? That might inform other potential solutions, since you already mentioned forms in your second post.

2 Likes