Skip to main content
CallHQ provides a robust session-based approach for maintaining conversation context across multiple chat interactions. Session-Based Context Management:
  • sessionId - Groups multiple chats under a persistent session
  • Automatic Context Preservation - All messages within a session maintain conversation history
  • Easy Session Management - Create, use, and retrieve sessions with simple API calls

Prerequisites

  • Completed Chat quickstart tutorial
  • Basic understanding of chat requests and responses

How Sessions Work

Sessions in CallHQ provide a persistent container for conversations. Once you create a session, all subsequent messages sent to that session automatically maintain context and conversation history.
Important Session Information:
  • Sessions expire automatically after 24 hours by default
  • After expiration, you’ll need to create a new session to continue conversations
  • Web chat widget and SMS conversations automatically manage session creation and expiration
  • You don’t need to manually create or manage sessions when using these channels
1

Create a session

Start by creating a new chat session with your assistant:
Create Session
2

Get session ID from response

The response will include your session ID:
Session Response
3

Use session ID in all related chats

Send messages using the session ID to maintain context:
First Chat in Session

TypeScript Session Manager

Here’s a complete TypeScript implementation for managing chat sessions:
session-manager.ts

Multi-Session Workflows

For complex applications that need multiple concurrent conversations, you can manage multiple sessions:
multi-session-manager.ts

Session Lifecycle Management

Creating Sessions

  • Sessions are created with a name and assistant ID
  • Each session gets a unique identifier
  • Sessions start in “active” status

Using Sessions

  • Send messages using the session ID
  • All messages within a session maintain context
  • Sessions automatically track conversation history

Session Expiration

Session Expiration Rules:
  • Sessions expire automatically after 24 hours by default
  • After expiration, you’ll need to create a new session to continue conversations
  • Web chat widget and SMS conversations automatically manage session creation and expiration
  • You don’t need to manually create or manage sessions when using these channels

Retrieving Session Data

  • Get conversation history for any active session
  • View all messages in chronological order
  • Monitor session status and metadata

Best Practices

Session Naming

Session Organization

Error Handling


Webhook Support

Sessions support the following webhook events through server messaging:
  • session.created - Triggered when a new session is created
  • session.updated - Triggered when a session is updated
  • session.deleted - Triggered when a session is deleted
To receive these webhooks, go to your Assistant page in the Dashboard and navigate to “Server Messaging” and select the events you want to receive.These webhooks are useful for tracking session lifecycle, managing session state in your own database, and triggering workflows based on session changes.

Next Steps

Need help with session management? Contact our team at hello@callhq.ai or visit our Dashboard.