# SoftBank Robotics documentation What's new in NAOqi 2.8?

# QiChat - Introduction

NAOqi Interaction engines - Table of Content | Introduction | Syntax | Overview | Cheat Sheet

## Topic

A Topic is a script box (or file) containing Rule.

Its header contains at least the name and the language of the topic.

Example

    topic: ~introduction ()
    language: English

    u:(hello) hello human, pleased to meet you

To create your first Topic, see: Creating Dialog boxes.

## Rule

A Rule associates a Human input (what the human says) with a relevant Robot output (what the robot answers).

Delimiters, Special characters and Rule functions and properties allows you to create powerful rules, managing in one line lots of different cases.

There are three type of rules: User rule, User subrule and Proposal.

## Human input

Human input is Part of a User rule or a User subrule delimited by parentheses and containing the message to be recognized by the robot.

When the Human input matches, i.e. the message is recognized, the Rule is triggered.

When a Rule is triggered:

- the Robot output is executed (said and/or done).
- the Focus is set to the Topic containing the rules.

## Robot output

Part of a User rule, User subrule, or a Proposal containing what the robot says and/or does when the rule is triggered.

Warning

Dialog engine will always try to reduce number of call to TextToSpeech to avoid pause in response. Dialog engine will try to evaluate all your answer before send it to TextToSpeech

## Concept

A Concept is a list of words and/or phrases that refer to one idea.
For example, a list of countries, a list of names, synonyms of a word.

They can be used both in Human input or Robot output.

There are two types of Concepts:

Type | Scope | At run time ... | May contain ...
--- | --- | --- | ---
Static | global | cannot be modified | Choice: [ ], Optional part: { }, concepts (static and dynamic), functions (^rand, ^first), Variable: $ and Conditions: == > <> <.
Dynamic | local to a Topic | must be modified | a list of words or phrases between a single Choice: [ ].

Examples

    concept:(want) ^rand {"i'd * like" "i want {"a lot"}"}

    dynamic:want

    python:
    setConcept("want","enu", ["i'd like" "i want" "i want a lot"]

Syntax

- To declare a Concept, see: concept and dynamic.
- To use a Concept, see: Concept call: ~.

## Activated / deactivated

Topics and rules must be activated to be taken in account by the Dialog engine.

It is possible to activate and deactivate a part of them in order to create conversational contexts and/or reduce the number of rules managed in the memory.

### Topic activation

In Choregraphe, a Topic is activated or deactivated when the Dialog topic box is loaded and unloaded.

By script, you can also use:

- `ALDialogProxy::activateTopic`
- `ALDialogProxy::deactivateTopic`

### Rule activation

All the Rules of a deactivated Topic are also deactivated.

All the Rules of an activated Topic are activated, except if the rule:

- is a User subrule and is not attached to the last triggered Rule,
- is an already executed Proposal,
- contains a deactivated tag,
- contains the ^private function, while its Topic has not the Focus.

## Focus

Several Topics can be activated simultaneously, but only one Topic at a time has the Focus.

The Focus is given to the Topic containing the last triggered rule, except if it has the ^noStay property.

If similar rules are duplicated in several topics, then the topic with the focus has the priority, otherwise the choice is random.

In some cases, Dialog engine can decide by itself to give the Focus to a topic and say his first proposal. ^noPick function allows to prevent this automatic selection.

Related functions and properties

- ^noPick,
- ^noStay,
- ^resetOnFocus,
- ^fallback.

## Recover section

Rules placed after the recover section have a lower priority level.

### recover:

Syntax

    recover:

Usage

Rules placed after the recover section have a lower priority level.

Example

    topic: ~topic1()
    language: English

    u:(alien) I am not an alien, I am a humanoid robot

    recover:
    u:(hello) hello human

Execution

    > hello alien
    I am not an alien, I am a humanoid robot

## Priority among rules

The rules are taken into consideration following this order:

Order | All the rules located in the ...
--- | ---
1 - Focus | Main section of the topic having the Focus.
2 - All topics | Main section of all the other activated topics, ^fallback excepted - randomly ordered.
3 - Recover | Recover sections of all activated Topics.
4 - Fallback | Main section of the activated topics having the ^fallback property.

## Semantic Engine & Collaborative Dialog

During a Collaborative Dialog, the Semantic Engine is activated. So, be aware of the additional content it bring.

For further details, see: Semantic Engine - What Pepper knows.

## Semantic Engine & QiChat rules

The semantic engine memorizes all the sentences previously said by the robot.

So Pepper may remember and rephrase what he has already said from a hard coded content.

Example:

    Human: do you have a brother?

    Robot: All my developers are my family!

(QiChat content)

    Human: what is your family?
    Robot: My developers

(Semantic Engine memory)

## Priority among rules in a Collaborative Dialog

In a Collaborative Dialog, the Priority order mixes QiChat Rules and Semantic Engine contribution.

Order | All the rules located in the ...
--- | ---
1 - Focus | Main section of the topic having the Focus.
2 - All topics | Main section of all the other activated topics, ^fallback excepted - randomly ordered.
3 - Recover | Recover sections of all activated Topics.
4 - Semantic Engine | Answers from Semantic Engine.
5 - Fallback | Main section of the activated topics having the ^fallback property.
6 - Semantic Engine | Semantic reformulation of the question to say that Pepper doesn’t know the answer.

## Reusing human input

It is possible to store a part of the human input in order to reuse it in the robot answer.

For further details, see: Input storing: _.

## Variables and events

ALDialog uses ALMemory to store and retrieve data.

Any stored data can be seen as a variable or as an event.

For further details, see: variable and event.

## Skin

A Skin is a meta rule, defining transformations to be applied on already defined Robot outputs.

A Skin can be placed in any Topic and is triggered when a Robot output matches.

For further details, see: Transformation rules.

Glossary Site map Index Support Contact Legal Notices