Bookmark & BookmarkStatus


level_1


Bookmark

A Bookmark represents an identifier for a rule inside a topic.

See also javadoc: Bookmark.

BookmarkStatus

A BookmarkStatus allows you to read and write the status of a Bookmark and to know when it is reached.

Each Bookmark can be disabled: the corresponding rule will not be matched and the robot will not say the proposal from this rule either.

See also javadoc: BookmarkStatus.

How to use it

Retrieving bookmarks

Get all the bookmarks contained in a Topic:

Topic topic = ...;
Map<String, Bookmark> bookmarks = topic.getBookmarks();

Controlling a Bookmark status

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

Bookmark bookmark = ...;
BookmarkStatus bookmarkStatus = qiChatbot.bookmarkStatus(bookmark);

bookmarkStatus.setEnabled(false);
Boolean isEnabled = bookmarkStatus.getEnabled();
bookmarkStatus.addOnEnabledChangedListener(enabled -> Log.i(TAG, "onEnabledChanged: " + enabled));

How to know when a bookmark is reached

The BookmarkStatus allows you to add a listener to react when a Bookmark is reached:

Bookmark bookmark = ...;
BookmarkStatus bookmarkStatus = qiChatbot.bookmarkStatus(bookmark);

bookmarkStatus.addOnReachedListener(() -> Log.i(TAG, "onReached"));