Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

AI sessions

An AI session groups multiple sendAI turns under one id so the platform can maintain context across follow-up questions. Pass sessionId on subsequent calls to continue the same conversation.

How sessions work

  Turn 1                          Turn 2
  ──────                          ──────

  sendAI({ message })             sendAI({
    (no sessionId)                  sessionId: "<from turn 1>",
  })                                message: { text: "follow-up" }
       β”‚                                 β”‚
       β–Ό                                 β–Ό
  new session id created          same session continued

On the first call, omit sessionId (or pass null). The SDK generates a session id and returns it in the response metadata.

On follow-up calls, pass that id as sessionId.

Sessions are tied to senderId. Use a stable user id per end user or support ticket.

Extracting sessionId (first turn)

const first = await notifier.sendAI({
  senderId: "user-123",
  message: { text: "Start a new support session." },
});

const sessionId =
  first?.metadata?.packet?.id ??
  first?.metadata?.id;

Store sessionId in your database keyed by user, ticket, or chat thread.

Continuing a session

Sessions vs messages[] history

Approach
When to use

sessionId

Server-managed continuity; simpler client code

Full messages[] each call

You control exact context window; stateless servers

fetchAIHistory

Audit or rebuild UI from stored turns β€” see AI history

Transport

Use transport: "http" for session continuation.

Language guides

Language
Guide

JavaScript / TypeScript

Dart / Flutter

Next steps

Last updated