What is it¶
BaseChatbot is an abstract class that is the parent class of all custom
This class must be inherited to implement your own Chatbot on the tablet.
See also javadoc: BaseChatbot.
How to use it¶
Create a class that inherits
BaseChatbot and implement the required methods, especially
An instance of this custom class can then be provided to the method that creates a Chat action, along with any other chatbot.
Chatbot requires an available remote speech recognition.
In order to handle properly any error or slowness, it is recommended to create a standard QiChatbot, able to provide a minimal vocal interaction to the robot and to catch the not understood cases.
For further details, see: Managing not understood cases.
It is also possible to implement a simple fallback behavior thanks to a ReplyReaction with ReplyPriority.FALLBACK.
For further details see: StandardReplyReaction.
See also Managing availability incidents or planned non listening states with isAvailableToReply in order to avoid incorrect conversation feedbacks.
To be used within a
Chatbot should at least implement:
replyTo(phrase, locale): Produces a ReplyReaction based on a given input phrase.
acknowledgeHeard(phrase, locale): Informs the
Chatbotwith the last phrase heard by the robot. It will be called anytime a reply not given by this
Chatbothas been chosen.
acknowledgeSaid(phrase, locale): Informs the
Chatbotwith the last phrase said by the robot. It will be called anytime a ChatbotReaction not given by this
Chatbothas been chosen.
Extend BaseChatbot to implement your own
Chatbot, according to this interface.
This method is called by the chat when the robot hears something recognized as a
Phrase. The returned value is a possible
reply that the chat may select as its answer, among other chatbots replies (if any).
replyTo implementation must return a
StandardReplyReaction which is the standard implementation of
ReplyReaction that is returned may obviously be run as an uttered sentence, but it may also be any other action or
combination of actions, such as an animation synchronized with an uttered answer for example.
The different effective behaviors of the replies, according to the input phrase, may be provided by several implementations of
BaseChatbotReaction that can be passed as a parameter of the returned
If the chatbot has no answer for the input phrase, the implementation of
replyTo must throw a
For further details, see: StandardReplyReaction.
As an answer to a phrase, a
Chatbot will create a
A reply reaction contains at least:
ReplyPriority, used by the chat to determine which
ReplyReactionis chosen for a given user sentence.
ChatbotReaction, executed if the chat chooses it to answer a given user sentence.
See also javadoc:
ChatbotReaction should at least have the following interface:
runWith(SpeechEngine): runs the
ChatbotReactionwill most likely make the robot speak but can also make him move, display things on the tablet and so on.
stop(): stops the
ChatbotReaction. The stop method will be automatically called when
Chataction stopped. Developer should ensure every action, robotic or not, will be stopped.
Extend BaseChatbotReaction to implement your own
Managing availability incidents or planned non listening states with isAvailableToReply¶
isAvailableToReply is set to true, meaning your chatbot is ready
to process any input.
If any kind of of technical incidents, such as a network shortage or a usage quota exceeded,
or if your chatbot cannot / should not answer to the user at the moment,
then you should set
isAvailableToReply to false. This way, the Chat will be able to manage
correctly the conversation feedbacks: if no chatbot is available, then the robot
will switch to a non-listening state.
For further details, see: Conversation Feedbacks.
Optional methods to implement¶
acknowledgeSaid methods may be implemented if
necessary. Their default implementation is to do nothing.
These methods are called by the chat to inform your custom chatbot that another
chatbot’s reply has been chosen.
This is an opportunity for a chatbot to keep the context of the discussion, even if its own replies are not selected by the chat engine.
If the chat contains only one chatbot, these methods will never be called.