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.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 createdsession.updated- Triggered when a session is updatedsession.deleted- Triggered when a session is deleted
Next Steps
- Chat Examples - See more session management patterns
- API Reference - Complete API documentation for sessions