A QiChatbot
is a type of chatbot using Topics .
Main QiChatbot
features are:
Embedded speech recognition results will be better than remote when:
See also API doc: 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)
.withResource(R.raw.shop)
.build()
// Create a QiChatbot
val qichatbot: QiChatbot = QiChatbotBuilder.with(qiContext)
.withTopic(topic)
.build()
// Create a topic
Topic topic = TopicBuilder.with(qiContext)
.withResource(R.raw.shop)
.build();
// Create a QiChatbot
QiChatbot qichatbot = QiChatbotBuilder.with(qiContext)
.withTopic(topic)
.build();
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)
.withTopic(topic)
.build()
// Create a Chat
val chat: Chat = ChatBuilder.with(qiContext)
.withChatbot(qichatbot)
.build()
// 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" )
fchat.requestCancellation()
}
// 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();
});
When building your set of topics, make sure it manages correctly these different pitfalls:
All these cases, should be managed systematically.
For further details, see:
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
qichatbot.setSpeakingBodyLanguage(BodyLanguageOption.DISABLED);
See also: Disabling the body language while listening.
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.
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:
When asking for recommendations, the maxRecommendations parameter is used to indicate the maximum amount of recommendations to provide.
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 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 correspond to all the activated sub-rules of the current scope.
val scopeRecommendations: List<Phrase> = qiChatbot.scopeRecommendations(3)
List<Phrase> scopeRecommendations = qiChatbot.scopeRecommendations(3);