Skip to main content

ChatSession

A single conversation session between a subscriber and a bot, including messages, live chat events, and metadata. Collection: chat-sessions | DB: MongoDB Source: hbf-core/src/main/java/gr/helvia/hbf/core/domain/ChatSession.kt TypeScript: hbf-core-api/src/datamodel/chat_session.ts

Fields

FieldTypeRequiredIndexedNotes
idStringyesPKMongoDB document ID
uuidStringyesyes (unique)External session identifier
durationLongyesIn milliseconds, default 0
messagesList<ChatSessionMessage>yesEmbedded. See chat-session-message.md
messageCountIntyes
summaryStringnoAI-generated summary
sentimentStringno
resolutionStringno
urgencyStringno
featuresHashMap<String, Any>no
csatSurveysSet<ChatSessionCSATSurvey>noCSAT survey responses
statusChatSessionStatusyesDefault: ACTIVE
subscriberHandleStringnoPlatform subscriber ID
languageLanguageCodeno
tagsSet<String>no
tenantTenantno@DBRef lazy
organizationIdStringyes
lastInteractionDateyes
conversationNodesList<ChatSessionConversationNode>yesVisited nodes
intentsHashMap<String, Int>noIntent name to hit count
createdAtDateyesyes@CreatedDate
updatedAtDateyes@LastModifiedDate
containsUserInteractionBooleanyesDefault: false
userInteractionCountIntyes
liveChatsList<LiveChatSession>noAccepted live chat sessions
metadataChatSessionMetadatanoDeployment and subscriber info
variablesSet<ChatSessionVariableMapping>noSession-level variable values

Nested Objects

ChatSessionMetadata

FieldTypeNotes
subscriberNameString
subscriberEmailString
subscriberCustomDataBasicDBObject
deploymentIdString
deploymentNameString
platformOriginString
deploymentPlatformString
isSubscriberNewBoolean

ChatSessionConversationNode

FieldTypeNotes
nodeIdStringConversation node ID
appearancesIntNumber of times visited

ChatSessionVariableMapping

FieldTypeNotes
nameStringVariable name
valueStringVariable value

ChatSessionCSATSurvey

FieldTypeNotes
idStringCSAT node response ID
nameStringVariable name
statusString"PRESENTED" or "ANSWERED"
sectionsScoreMap<String, Int>Section name to score

LiveChatSession

Embedded analytics for a live chat session within a ChatSession. Written by DataCollector in hbf-bot during live chat event processing. See docs/architecture/flows/live-chat.md for the full data flow.

FieldTypeNotes
waitingTimeLongSeconds waiting for agent (request to accept)
liveChatEventTypeLiveChatEventTypeDefault: LIVECHAT_REQUESTED. Final state is usually LIVECHAT_TERMINATED
durationLongIn seconds, default 0. Full conversation duration (request to terminate)
responseTimeList<Long>Per-agent first response times in seconds
updatedAtDateLast update timestamp
lastEndUserMessageAtDateTimestamp of last end-user message
lastSenderLiveChatSenderEND_USER or AGENT
conversationIdStringLCM conversation ID (matches livechat_conversation.id in LCM MySQL)
agentsSet<String>Agent email addresses (e.g., kostas.setzas@helvia.ai)
tagsList<String>

Source: hbf-core/src/main/java/gr/helvia/hbf/core/domain/LiveChatSession.kt

Compound Indexes

  • (organizationId, tenant.$id, status, lastInteraction) - session management queries
  • (organizationId, createdAt, tenant.$id, metadata.deploymentId, duration, liveChats) - analytics
  • (organizationId, tenant.$id, createdAt, metadata.deploymentId, csatSurveys.status) - CSAT analytics
  • (organizationId, tenant.$id, updatedAt) - recent updates
  • (messages._id) - message lookup

Enums

ChatSessionStatus

ValueDescription
ACTIVESession in progress
COMPLETEDSession ended

LiveChatEventType

ValueDescription
LIVECHAT_INITIALIZEDLive chat initialized
LIVECHAT_REQUESTEDEnd-user requested live chat
LIVECHAT_REQUEST_CLOSEDRequest closed
LIVECHAT_REQUEST_ACCEPTEDAgent accepted request
LIVECHAT_REQUEST_MISSEDRequest missed by agents
LIVECHAT_TERMINATION_REQUESTEDTermination requested
LIVECHAT_TERMINATEDLive chat terminated
LIVECHAT_ABANDONEDLive chat abandoned
LIVECHAT_TRANSFERREDTransferred to another agent
LIVECHAT_MESSAGE_EXCHANGEDMessage exchanged
LIVECHAT_MESSAGE_TYPINGTyping indicator
LIVECHAT_IS_DISABLEDLive chat is disabled
LIVECHAT_REQUEST_EXISTSDuplicate request
LIVECHAT_OUT_OF_BUSINESS_HOURSOutside business hours
LIVECHAT_IS_IN_PROGRESSAlready in progress
LIVECHAT_GENERIC_ERRORGeneric error
SOURCE_REQUEST_NEW_HANDOVERITC: new handover requested (old: LIVECHAT_REQUESTED_OLD)
SOURCE_PRE_REQUEST_NEW_HANDOVERITC: pre-request handover (old: LIVECHAT_INITIALIZED_OLD)

LiveChatSender

ValueDescription
END_USERMessage from end user
AGENTMessage from live agent

Relationships

  • Belongs to: Tenant (via @DBRef), Organization (via organizationId)
  • Contains: ChatSessionMessage (composition), LiveChatSession (composition)
  • Referenced by: Survey (via @DBRef)

TypeScript Mapping

hbf-core (Kotlin)hbf-core-api (TypeScript)Notes
ChatSessionChatSessionDTOTS uses DTO suffix
ChatSessionMessageChatSessionMessageDTOSee chat-session-message.md
LiveChatSessionLiveChatSessionDtoAligned. TS has tags omitted
ChatSessionCSATSurveyChatSessionCSATSurveyAligned
ChatSessionConversationNodeChatSessionConversationNodeAligned
ChatSessionVariableMappingChatSessionVariableMappingAligned. TS value is optional
ChatSessionMetadataobjectTS types metadata as generic `object
ChatSessionStatusChatSessionStatusesDifferent naming
LiveChatEventTypeLiveChatEventTypeTS adds LIVECHAT_CALL_REQUESTED
LiveChatSenderLiveChatSenderAligned