Topic & TopicStatus ¶
Topic represents a conversational topic for a QiChatbot.
It groups together different rules defining Human-robot verbal interactions.
See also javadoc: Topic.
TopicStatus allows you to read and write the status of a
Topic can be disabled: its rules will not be matched and the robot will
not say proposals from those either.
At most one
Topic can be focused at a time: it means this topic is the one
where a rule was matched last.
See also javadoc: TopicStatus.
How to use it¶
Configuring a QiChatbot¶
Topic from a topic file (.top) and create a QiChatbot with it:
Topic topic = TopicBuilder.with(qiContext) .withResource(R.raw.animals) .build(); QiChatbot qiChatbot = QiChatbotBuilder.with(qiContext) .withTopic(topic) .build();
Get all the topics contained in a QiChatbot:
QiChatbot qiChatbot = ...; List<Topic> topics = qiChatbot.getTopics();
Controlling a Topic status¶
TopicStatus from a
TopicStatus will be able to read and write the specified
Topic topic = ...; TopicStatus topicStatus = qiChatbot.topicStatus(topic); topicStatus.setEnabled(false); Boolean isEnabled = topicStatus.getEnabled(); topicStatus.addOnEnabledChangedListener(enabled -> Log.i(TAG, "onEnabledChanged: " + enabled)); Boolean isFocused = topicStatus.getFocused(); topicStatus.addOnFocusedChangedListener(focused -> Log.i(TAG, "onFocusedChanged: " + focused));