Definition

A label is a kind of reusable template.

Here is an example :

? HELLO
    - {MY_LABEL}

? HELLO JOHN
    - {MY_LABEL}

[MY_LABEL]
    - Hello there

In this script, MY_LABEL is label, the syntax follows this rules :

  1. Starts a line
  2. Label identifier are between square brackets
  3. Label identifier is composed of letters only and underscores.
  4. Label is followed by templates

In that case, each templates call the label ‘MY_LABEL’, so the rendered template is Hello there

Parameters

A label can define parameters :

? HELLO
    - {MY_LABEL}

? HELLO JOHN
    - {MY_LABEL("John")}

[MY_LABEL(name)]
    - Hello %name

MY_LABEL now defines a ‘name’ parameter, and can be used in template.

  1. Hello -> Hello
  2. Hello john -> Hello John

A label can have multiple Parameters, the syntax follows this rules :

  1. all parameters are in curly brackets, between label identifier and closing square brackets
  2. parameters are separated by coma

To call a label with parameters, it follows the same rules, but you need to put values in double quotes.

Default

Athena defines a special label called : DEFAULT

This label is called each time the engine cannot find a matching scenario :

? HELLO
    - {MY_LABEL}

? HELLO JOHN
    - {MY_LABEL}

[MY_LABEL]
    - Hello there

[DEFAULT]
    - Sorry i did not get that

In this script, if the user says ‘Bye’, the agent will respond with ‘Sorry i did not get that’

Sub Scenarios

A label can have sub scenarios :

? HELLO
    - {MY_LABEL}

[MY_LABEL]
    - How are you today ?
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?

This is equivalent to :

? HELLO
    - How are you today ?
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?

Be wary that any sub scenario of the scenario will be overriden by the label’s sub scenario, even if none. To avoid this, cf. https://my.satisfaction.ai/docs/athena/en/labels.html#sub-scenarios-combined :

? HELLO
    - {MY_LABEL}
        ? GREAT
            - That's good :)
        ? TERRIBLE
            - Ohhhhhh

[MY_LABEL]
    - How are you today ?
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?

This is equivalent to : (The sub scenario is removed.)

? HELLO
    - How are you today ?
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?

Successive call label

A template can have successive calls to labels :

? HELLO
    - {YOUR_NAME} {MY_LABEL}
        ? GREAT
            - That's good :)
        ? TERRIBLE
            - Ohhhhhh

[YOUR_NAME]
    - Hello John

[MY_LABEL]
    - How are you today ?
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?

All call labels are generated, from the left to the right. Here we have two generations :

First :

? HELLO
    - Hello John {MY_LABEL}

[MY_LABEL]
    - How are you today ?
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?

You can notice in this example that the sub scenario is removed, even if the label YOUR_NAME doesn’t have a sub scenario.

Second :

? HELLO
    - Hello John How are you today ?
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?

Call label as parameter

A label with parameters can be called with a call to a label :

? HELLO
    - {YOUR_NAME("{BOT_NAME}")} {MY_LABEL}
        ? GREAT
            - That's good :)
        ? TERRIBLE
            - Ohhhhhh

[BOT_NAME]
    - Alf

[YOUR_NAME(bot_name)]
    - Hello John, my name is %bot_name

[MY_LABEL]
    - How are you today ?
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?

Never forget to surround the call label between double quotes !

Successive outputs are :

  1. {YOUR_NAME(“Alf”)} {MY_LABEL}
  2. Hello John, my name is Alf {MY_LABEL}
  3. Hello John, my name is Alf How are you today ?

Sub Scenarios combined

Because a call to a label override the current sub scenario, a syntax exists to modify the behavior :

? HELLO
    - {+MY_LABEL}
        ? GREAT
            - That's good :)
        ? TERRIBLE
            - Ohhhhhh

[MY_LABEL]
    - How are you today ?
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?

The + before the label identifier means that the sub scenario will be aggregated to the current sub scenario :

Which is equivalent to

? HELLO
    - How are you today ?
        ? GREAT
            - That's good :)
        ? TERRIBLE
            - Ohhhhhh
        ? FINE
            - Glad to hear that !
        ? BAD
            - What can I do for you ?