ChatBacklogHandler

since v11.32

The ChatBacklogHandler can be used to access chats within the backlog in the novomind iAGENT routing process. This handler is only available in the novomind iAGENT routing process.

An example usage of a ChatBacklogHandler would look like this:

import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.inject.Inject;
import com.novomind.ecom.api.iagent.backlog.BacklogChatInfo;
import com.novomind.ecom.api.iagent.backlog.ChatBacklogHandler;
import com.novomind.ecom.api.iagent.model.Category;
import com.novomind.ecom.api.iagent.model.Chat;
import com.novomind.ecom.api.iagent.model.User;

@Inject
private ChatBacklogHandler chatBacklogHandler;

public int getChatsQueuedCount(Category category) {
  return (int) chatBacklogHandler.stream()
    .filter(chat -> category == null || category.equals(chat.getCategory()))
    .filter(chatBacklogHandler.isRoutable())
    .count();
}

public Set<Chat> getActiveChats(User agent) {
  return chatBacklogHandler.stream()
    .map(chat -> chatBacklogHandler.getBacklogChatInfo(chat))
    .filter(Optional::isPresent)
    .map(Optional::get)
    .filter(backlogChatInfo -> backlogChatInfo.getActiveAgent().isPresent())
    .filter(backlogChatInfo -> backlogChatInfo.getActiveAgent().get().getId().equals(agent.getId()))
    .map(BacklogChatInfo::getChat)
    .collect(Collectors.toSet());
}