Bookmark & BookmarkStatus


level_1


Bookmark

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

See also API doc: 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 API doc: BookmarkStatus.

How to use it

Retrieving bookmarks

Get all the bookmarks contained in a Topic:

val topic: Topic = ...
val bookmarks: Map<String, Bookmark> = topic.bookmarks

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:

val bookmark: Bookmark = ...
var bookmarkStatus: BookmarkStatus = qiChatbot.bookmarkStatus(bookmark)

bookmarkStatus.enabled = false
var isEnabled: Boolean = bookmarkStatus.enabled
bookmarkStatus.addOnEnabledChangedListener { Log.i(TAG, "onEnabledChanged: $enabled") }

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:

val bookmark: Bookmark = ...
val bookmarkStatus: BookmarkStatus = qiChatbot.bookmarkStatus(bookmark)

bookmarkStatus.addOnReachedListener { Log.i(TAG, "onReached") }

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

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