Explanation of keyword matching and sub scenarios by example

We will study the behavior of keyword matching in different contexts, in order to understand how Athena works.

Pattern with keyword matching

We will start from a simple case study: information request

? WANT INFORMATION
    - Do you want to receive them by email or by mail?

Here we defined a pattern via the syntax ? WANT INFORMATION with keywords: WANT INFORMATION.

In order to access this scenario, the user’s sentence must contain all the keywords, and follow the defined order:

  • correct examples
    • I want information
    • I want information please
    • I want one or more information
  • incorrect examples
    • information (it’s missing want keyword)
    • Can I have information (the keyword want is not present)
    • information I want (despite the presence of the keyword, the order is not respected)

Variability

Now that we have examples that are incorrects, we are going to see how to correct this with variability.

We will first add the possibilities in other patterns

? WANT INFORMATION
? INFORMATION
? CAN HAVE INFORMATION
? INFORMATION WANT
    - Do you want to receive them by email or by mail?

We can also try something more global, and leave only what makes sense in the pattern:

? (WANT|WOULD|LIKE) (HAVE) INFORMATION
    - Do you want to receive them by email or by mail?

In the case below:

  • (WANT WOULD LIKE) means that we generate three different combinations
    • WANT (HAVE) INFORMATION
    • WOULD (HAVE) INFORMATION
    • LIKE (HAVE) INFORMATION
  • (HAVE) means that this keyword is optional
    • (WANT WOULD LIKE) HAVE INFORMATION
    • (WANT WOULD LIKE) INFORMATION

Here is the set of patterns covered by this syntax:

? WANT HAVE INFORMATION
? WOULD HAVE INFORMATION
? LIKE HAVE INFORMATION
? WANT INFORMATION
? WOULD INFORMATION
? LIKE INFORMATION

Conflicts

In the previous example, one might ultimately wonder: why not just leave INFORMATIONS. Attention to conflicts: a conflict in athena appears from the moment when two different scenarios obtain the same score.

? (GET) INFORMATION
    - Do you want to receive them by email or by mail?

? (SEND) INFORMATION
    - You can send us the information at this address: depot@xyz.com

In the 2 scenarios below, we accept the fact that they can be triggered using only one keyword INFORMATION. If the user says: give me information, Athena will not know which scenario to choose because both have INFORMATION in their pattern, and then will trigger a default.

sub-scenarios

In the next point, we define 2 sub scenarios that answer the question “Do you want to receive them by email or mail?”

? (WANT|WOULD|LIKE) (HAVE) INFORMATION
    - Do you want to receive them by email or by mail?
        ? MAIL
            - Ok, I send you this by mail
        ? EMAIL
            - Ok, I send you this by email

In this case, it is necessary that the answer of the user to the question contains either MAIL or EMAIL, if its answer contains the 2, then it will results in a default.

If a similar pattern is defined as a scenario, Athena always prefers the current sub-scenario:

? (WANT|WOULD|LIKE) (HAVE) INFORMATION
    - Do you want to receive them by email or by mail?
        ? MAIL
            - Ok, I send you this by mail
        ? EMAIL
            - Ok, I send you this by email

? BY MAIL
    - mail

Conversation:

Source text
user I would like to get information
bot Do you want to receive them by email or by mail?
user by mail
bot Ok, I send you this by mail

Sub scenarios and labels

The behavior changes when we use labels in the sub-scenarios, and that depends on the sub-scenarios defined in these labels.

? (WANT|WOULD|LIKE) (HAVE) INFORMATION
    - {SEND_INFORMATION}

[SEND_INFORMATION]
    - Do you want to receive them by email or by mail?
        ? MAIL
            - Ok, I send you this by mail
        ? EMAIL
            - Ok, I send you this by email

We have just created a label that contains the question of how to send information. Everything still works correctly: athena has as under scenario that of the label [SEND_INFORMATION]

If a label does not have sub-scenarios, then Athena will base itself on the following scenarios:

? (WANT|WOULD|LIKE) (HAVE) INFORMATION
    - {SEND_INFORMATION}
        ? MAIL
            - Ok, I send you this by mail
        ? EMAIL
            - Ok, I send you this by email

[SEND_INFORMATION]
    - Do you want to receive them by email or by mail?

Here the information request scenario has a sub-scenario, while [SEND_INFORMATION] does not have one. Athena in this case keeps the sub scenarios, the behavior is still what we expected.

However, when the current scenario defines sub-scenarios, and the label called has sub-scenarios, Athena applies a default behavior: retains only the last sub-scenarios:

? (WANT|WOULD|LIKE) (HAVE) INFORMATION
    - {SEND_INFORMATION}
        ? MAIL
            - Ok, I send you this by mail

[SEND_INFORMATION]
    - Do you want to receive them by email or by mail?
        ? EMAIL
            - Ok, I send you this by email

? BY MAIL
    - mail

Only the sub-scenario of [SEND_INFORMATION] is preserved:

Conversation:

Source text
user I’d like some information
bot Do you want to receive them by email or by mail?
user by mail
bot mail
user I’d like some information
bot Do you want to receive them by email or by mail?
user by email
bot Ok, I send you this by email

To combine the two, we can use a syntax on the call label {+SEND_INFORMATION}

? (WANT|WOULD|LIKE) (HAVE) INFORMATION
    - {+SEND_INFORMATION}
        ? MAIL
            - Ok, I send you this by mail

[SEND_INFORMATION]
    - Do you want to receive them by email or by mail?
        ? EMAIL
            - Ok, I send you this by email

? BY MAIL
    - mail

Conversation:

Source text
user I’d like some information
bot Do you want to receive them by email or by mail?
user by mail
bot Ok, I send you this by mail
user I’d like some information
bot Do you want to receive them by email or by mail?
user by email
bot Ok, I send you this by email