Unblu Agent Embedded JS API
    Preparing search index...

    Class UnbluConversationHistoryApi

    This class provides functionality around the conversation history

    Index

    Constructors

    Methods

    Constructors

    • Parameters

      • conversationHistoryModule: ConversationHistoryModule
      • apiStateProvider: ApiStateProvider

      Returns UnbluConversationHistoryApi

    Methods

    • Search for conversation history entries based on the provided query.

      The query allows filtering by various criteria, such as the creation timestamp, the conversation state, participant person IDs, and many more. Results can be sorted using the orderBy parameter and paginated using offset and limit.

      Parameters

      Returns Promise<ConversationHistoryDataResult>

      The search result containing matching conversation history entries

      UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

      // Search for ended conversations created in the last 7 days
      const result = await api.conversationHistory.search({
      searchFilters: [
      {
      field: ConversationHistorySearchFilterField.STATE,
      operator: {
      type: ConversationStateOperatorType.EQUALS,
      value: ConversationHistoryState.ENDED
      }
      },
      {
      field: ConversationHistorySearchFilterField.CREATION_TIMESTAMP,
      operator: {
      type: TimestampOperatorType.GREATER_THAN,
      value: Date.now() - 7 * 24 * 60 * 60 * 1000
      }
      }
      ],
      orderBy: [
      {
      field: ConversationHistoryOrderByField.CREATION_TIMESTAMP,
      order: Order.DESCENDING
      }
      ],
      limit: 50
      });

      console.log(`Found ${result.items?.length} conversations`);
      if (result.hasMoreItems) {
      console.log(`More items available at offset ${result.nextOffset}`);
      }