Vapi provides two approaches for maintaining conversation context across multiple chat interactions.
Two Context Management Methods:
previousChatId - Links individual chats in sequencesessionId - Groups multiple chats under a persistent sessionpreviousChatId and sessionId are mutually exclusive. You cannot use both in the same request.
Link chats together by referencing the ID of the previous chat.
Here’s a TypeScript implementation of the conversation chain:
Create a persistent session that groups multiple chats.
Here’s a TypeScript implementation of the session manager:
Use previousChatId when:
Use sessionId when:
Sessions are tied to one assistant. You cannot specify assistantId when using sessionId.
For workflows with multiple assistants, create separate sessions for each assistant.
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 deletedTo 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.