What is it

A QiChatbot is a type of chatbot using Topics .

Main QiChatbot features are:

  • Uses embedded speech recognition and remote speech recognition.
  • QiChatbot works without internet access (for example for confidentiality reasons).
  • Speech recognition will works even better with internet access, Chat action will automatically use embedded speech recognition and remote speech recognition.

Embedded speech recognition results will be better than remote when:

  • Listen less than one hundred sentences.
  • Use very rare words (for example products names).
  • Manage both type of conversation: proactive robot driven or human driven (robot wait for input)
  • State of the art chatbot script language named qiChat: discussion tree, variables, concepts, link with backend methods.
  • Multi-language.
  • Multi-modal: allows to use both speech recognition and any signals.

See also API doc: QiChatbot

How to use it

Creating a QiChatbot

Build a QiChatbot from a list of Topics. A Topic is created from a topic file (.top), and uses QiChat syntax.

See also QiChat Language.

shop.top content:

topic: ~shop()

concept:(buy) [buy purchase]

# human driven discussion with one level depth
u: (~buy) Do you want to buy wine or beer ?
    u1: (wine) Let me show you my wines. ^endDiscuss(wine)
    u1: (beer) Let me show you my beers. ^endDiscuss(beers)
    u1: (_*) i can't answer for $1 . Do you want to buy wine or beer ? ^stayInScope

Java code:

// Create a topic
val topic: Topic = TopicBuilder.with(qiContext)

// Create a QiChatbot
val qichatbot: QiChatbot = QiChatbotBuilder.with(qiContext)
// Create a topic
Topic topic = TopicBuilder.with(qiContext)

// Create a QiChatbot
QiChatbot qichatbot = QiChatbotBuilder.with(qiContext)

Ending a chat

Cancelling a QiChatbot does not cancel the Chat that handles it, the other chatbots will still be able to reply to user sentences. If you want to stop the chat when a qiChatbot is stopped you must track the state of the QiChatbot and manually stop the chat when the QiChatbot ends.

// Create a QiChatbot
val qichatbot: QiChatbot = QiChatbotBuilder.with(qiContext)

// Create a Chat
val chat: Chat = ChatBuilder.with(qiContext)

// Execute the chat asynchronously
val fchat: Future<Void> = chat.async().run()

// Stop the chat when the qichatbot is done
qichatbot.addOnEndedListener { endReason ->
    Log.i(TAG, "qichatbot end reason = $endReason" )
// Create a QiChatbot
final QiChatbot qichatbot = QiChatbotBuilder.with(qiContext)

// Create a Chat
final Chat chat = ChatBuilder.with(qiContext)

// Execute the chat asynchronously
final Future<Void> fchat = chat.async().run();

// Stop the chat when the qichatbot is done
qichatbot.addOnEndedListener(endReason -> {
    Log.i(TAG, "qichatbot end reason = " + endReason);

Managing not understood cases

When building your set of topics, make sure it manages correctly these different pitfalls:

  • The remote speech recognition is not available (think about WiFi issue for instance),
  • The human does not speak loud nor clear,
  • The human says something unexpected,
  • The robot answers you defined uses an undefined variable.

All these cases, should be managed systematically.

For further details, see:

Disabling body language while speaking

By default, Pepper doesn’t stay motionless while speaking, he makes relevant gestures according to what he is saying: this is his body language.

You can choose to keep this behaviour or to disable it with a setSpeakingBodyLanguage.

To disable the body language, use BodyLanguageOption.DISABLED:

qiChatbot.speakingBodyLanguage = BodyLanguageOption.DISABLED

See also: Disabling the body language while listening.

Managing recommendations

One part or your dialog system may display useful recommendations to help users in front of the robot. QiChatbot API allows to retrieve displayable recommendations from written topics. If a rule is u:(i [want need] {“to rent”} a car) then a recommendation could be “i want a car” that you can display directly in your recommendation system. Recommendations are randomly generated.

Retrieving recommendations

Recommendations give you access to the verbal inputs available to the user to interact with the robot when using a QiChatbot.

The QiChatbot object provides 3 different recommendation types:

  • global recommendations,
  • focused topic recommendations,
  • scope recommendations.

When asking for recommendations, the maxRecommendations parameter is used to indicate the maximum amount of recommendations to provide.

Global recommendations

Global recommendations correspond to all the activated u: rules loaded in the QiChatbot (except private rules).

val globalRecommendations: List<Phrase> = qiChatbot.globalRecommendations(3)
List<Phrase> globalRecommendations = qiChatbot.globalRecommendations(3);

Focused topic recommendations

Focused topic recommendations correspond to all the activated u: rules in the currently focused topic. It may include private rules.

val focusedTopicRecommendations: List<Phrase> = qiChatbot.focusedTopicRecommendations(3)
List<Phrase> focusedTopicRecommendations = qiChatbot.focusedTopicRecommendations(3);

Scope recommendations

Scope recommendations correspond to all the activated sub-rules of the current scope.

val scopeRecommendations: List<Phrase> = qiChatbot.scopeRecommendations(3)
List<Phrase> scopeRecommendations = qiChatbot.scopeRecommendations(3);