QiChatbot


level_3


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 javadoc: 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
Topic topic = TopicBuilder.with(qiContext)
                          .withResource(R.raw.shop)
                          .build();

// Create a QiChatbot
QiChatbot qichatbot = QiChatbotBuilder.with(qiContext)
                                      .withTopic(topic)
                                      .build();

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 QiChatbtot ends.

// Create a QiChatbot
final QiChatbot qichatbot = QiChatbotBuilder.with(qiContext)
                                            .withTopic(topic)
                                            .build();

// Create a Chat
final Chat chat = ChatBuilder.with(qiContext)
                             .withChatbot(qichatbot)
                             .build();

// 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);
    fchat.requestCancellation();
});

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 a Chat action is running.

The Chat action provides 3 different recommendation types:

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

Global recommendations

Global recommendations correspond to all the activated u: rules loaded in the Chat action.

PhraseSet globalRecommendations = chat.globalRecommendations();

Focused topic recommendations

Focused topic recommendations correspond to all the activated u: rules in the currently focused topic.

PhraseSet focusedTopicRecommendations = chat.focusedTopicRecommendations();

Scope recommendations

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

PhraseSet scopeRecommendations = chat.scopeRecommendations();