Interface ConversationManager


@NonNullByDefault public interface ConversationManager
The ConversationManager is responsible for managing the lifecycle and persistence of Conversations.

Implementations should:

  • Automatically persist a persistable Conversation whenever a message is added or messages are removed.
  • Emit ConversationEvent implementations accordingly.
  • If a conversation has a blank ID, no events will be emitted.
Author:
Florian Hotze - Initial contribution
  • Method Details

    • getConversation

      default Conversation getConversation(String id)
      Gets a conversation by its identifier.

      If no conversation with that ID exists, create a new conversation.

      Parameters:
      id - the unique identifier of the conversation
      Returns:
      the conversation
    • getConversation

      @Nullable Conversation getConversation(String id, boolean createIfMissing)
      Gets a conversation by its unique ID.
      Parameters:
      id - the unique identifier of the conversation
      createIfMissing - whether to create a conversation with the provided id if none exists
      Returns:
      the conversation
    • removeConversation

      void removeConversation(String id)
      Explicitly removes a conversation storage.
      Parameters:
      id - the conversation identifier
    • getConversations

      Collection<Conversation> getConversations()
      Returns all currently active or stored conversations.
      Returns:
      a collection of all conversations
    • setHistoryLimit

      void setHistoryLimit(int limit)
      Sets the maximum number of messages to keep in a conversation history.
      Parameters:
      limit - the maximum number of messages