Topic & TopicStatus


level_1


Topic

A Topic represents a conversational topic for a QiChatbot. It groups together different rules defining Human-robot verbal interactions.

See also javadoc: Topic.

TopicStatus

A TopicStatus allows you to read and write the status of a Topic.

Each 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

Build a 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();

Retrieving topics

Get all the topics contained in a QiChatbot:

QiChatbot qiChatbot = ...;
List<Topic> topics = qiChatbot.getTopics();

Controlling a Topic status

Create a TopicStatus from a Topic. This TopicStatus will be able to read and write the specified Topic status:

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));