Definition

A template defines the response that will be sent to the user

? HELLO
    - Hello you

The syntax of a template is this one :

One tabulation + the parent pattern tabulations (0 in this case) followed by a dash and a space.

You can define more than one template as the response for a scenario. The system will randomly pick one of them.

? HELLO
    - Hello you
    - Hello there
    - Hi

WARNING The template is not multiline, you can’t write a single template on more than one text line.

Conditional template

Like pattern conditions, a template can be conditionaly elected :

? HELLO
    - Hello
    - Hi
    -| @Time.BeforeNoon()
    - Good morning
    -| @Time.AfterNoon()
    - Good afternoon 

It always starts with a dash , followed by pipe and a space.

The condition is expressed using an addin, or with code style syntax.

This allows in this example to elect a different template based on time of day.

If no condition is accepted, it will default to one of the non conditioned template (‘Hello’ or ‘Hi’ in this case)

Template statement

The template statements allows you to execute instructions before template is rendered.

? HELLO
    -: @User.FirstHello("true")
    - Hello

Template continuation

To send one message into multiple response, athena has a syntax to split a template:

? HELLO    
    - Hello John
    -& What can I do for you today ?

This will send two messages to the user, first one “Hello John”, and the second one “What can I do for you today ?”

limitations

Currently the message is splitted after all template continuation has been rendered. So we can’t apply different data to each text messages.

All Outgoing data will be sent with the first text message.

Templates and sub scenarios

When using multiple templates inside a scenario, we’d like those templates to have different scenarios. That’s something possible, but not obvious because of an Athena limitation.

Here is the example:

? HELLO
    - How are you?
    -| @datetime.inTimeRange("19:00","21:00", "Europe/London")
    - Hey, how was dinner?

2 different questions in this case, we need to have 2 different subscenarios. The logical way would be:

// THIS CODE IS INVALID !!!!!!!
? HELLO
    - How are you?
        ? GOOD
            - I'm happy for you
        ? BAD
            - Could you tell me what's wrong?
    -| @datetime.inTimeRange("19:00","21:00", "Europe/London")
    - Hey, how was dinner?
        ? GOOD
            - I'm sure it was pizza
        ? BAD
            - I'll be better tomorrow
// THIS CODE IS INVALID !!!!!!!            

But Athena in this case has an unexpected behavior, here is the result:

? HELLO
    - How are you?
    -| @datetime.inTimeRange("19:00","21:00", "Europe/London")
    - Hey, how was dinner?
// Patterns are grouped at the end, and are subscenarios in both questions
        ? GOOD
            - I'm happy for you
        ? BAD
            - Could you tell me what's wrong?
        ? GOOD
            - I'm sure it was pizza
        ? BAD
            - I'll be better tomorrow

In this case it’s bad, because the user will always end up into a default (Pattern Conflict)

But hey, there’s an alternative: Labels

? HELLO
    - {HELLO_NOT_DINNER}
    -| @datetime.inTimeRange("19:00","21:00", "Europe/London")
    - {HELLO_DINNER}

[HELLO_NOT_DINNER]
    - How are you?
        ? GOOD
            - I'm happy for you
        ? BAD
            - Could you tell me what's wrong?

[HELLO_DINNER]
    - Hey, how was dinner?
        ? GOOD
            - I'm sure it was pizza
        ? BAD
            - I'll be better tomorrow

Using this syntax, Athena will correctly process sub scenarios, and it offers a more readable script.