6. Strong Context

This session demonstrates how your Virtual Tutor may control the conversation threads through "strong" context. Yes, you need to use contextual features heavily if you're building a business-logy oriented application like Virtual Tutor.

The Problem

Let's look at the example chat as below.

  • Log 1
    • Hello! My name is Aco. What's your name?
    • My name is Jack.
    • Nice to meet you!
    • ...
  • Log 2
    • Hello! My name is Aco. What's your name?
    • I am Jack.
    • Nice to meet you!
    • ...
  • Log 3
    • Hello! My name is Aco. What's your name?
    • I am 9 years old.
    • Can you answer my question? What is your name please?
    • ...

As the logs above demonstrates, the Tutor is trying to teaching students to introduce their name. If the student gives a proper answer, saying "My name is Jack", she completes the dialog with "Nice to meet you!" Otherwise she repeats the question until the student gives his name in one of expected pattern.

What should we do to accomplish the above "controlled conversation"?

You have learned contextual cells in previous sessions and might have noticed the contextual cells work only when their Input matches the user message. For controlled conversation threads demonstrated above, we can of course write several contextual cells to handle the correct answers from students. But what should we do to catch these "wrong" answers? After all, there are unlimited possibility for the "wrong" answers...

The Solution

You need cells with strong context, which has <strong/> element placed in Context field, typically at the beginning. Different from normal contexts, strong contexts are processed BEFORE input.

Here are cells with strong context we may create for the controlled conversation above.

Examples

Example 1. Controlled thread

Note means Context field.

  • Cell 1
    • My name is Jack
    • <strong/>what is your name
    • Nice to meet you!
  • Cell 2
    • I am Jack
    • <strong/>what is your name
    • Nice to meet you!
  • Cell 3
    • *
    • <strong/>what is your name
    • Can you answer my question? What is your name please?

Let's look Cell 3, which catches all of the answers except ones defined with Cell 1 and Cell 2. If you haven't, check documentation for more information on * (Star). Basically, a * represents any one or more text.

So why the title of this session is "Strong Context" rather than "Star"? Star has a priority lower to specific text such as "I am 9 years old." Without <strong/> in context field, Cell 3 can be executed only if the user message doesn't match ANY other cells. That means, the dialogs may look at the below.

  • Log 4
    • Hello! My name is Aco. What's your name?
    • I am 9 years old.
    • So young so smart!
    • ...

The Tutor will give a comment on the age and thus loose the control on the conversation thread. With <strong/> element in Context field, Cell 3 will capture all answers that do not give name (as Cell 1 and 2 define) and thus repeat the question as Log 3 illustrates.

Things to Keep in Mind

  • * (star) may represent any text but its priority is lower to any specific text.
  • Place <strong/> at the beginning of Context where you want to control conversation threads.
  • Use <strong/> and * (star) together to create a catching-all cell to handle unwanted answers.