🔄Session Resumption
The session resumption feature lets users continue previous conversations without losing context, significantly improving the user experience.
How it works
When a sessionID is provided, AIsuru automatically checks whether the session is still valid:
Valid session: retrieves the conversation history and repopulates the chat, showing the Agent's last message
Invalid session: creates a new session and shows the welcome message
⏰ Important: Sessions expire after 1 hour of inactivity.
Getting the sessionID
From the AIsuru interface
The easiest way to find a session ID:
Go to the <img src="../.gitbook/assets/conversazioni.svg" alt="" data-size="line"> Conversations section of your Agent
Click <img src="../.gitbook/assets/URL.svg" alt="" data-size="line"> Open for the conversation you want
In the "Session information" section, you'll find the Session ID
Via JavaScript
To programmatically retrieve an active session ID:
javascript// Current sessionconst sessionID = getMemoriState().sessionID;// For a widget with a specific integrationIDconst sessionID = getMemoriState("my-integration-id").sessionID;Implementation
Web Component
React Component
Common use cases
Saving and resuming sessions
Integration with user authentication
Advanced integration via API
1. Retrieving Chat Logs (History)
There are two ways to retrieve past messages, depending on whether you already know the specific session or want to show the user a chronological list.
A. Retrieve a specific session
Use this if you already have a session ID and want to load the associated messages.
Endpoint: GET /memori/v2/SessionChatLogs/{sessionID}/{chatLogSessionID}
Note: passing the same ID in both parameters, the API will return the logs for that specific session.
B. Paginated chronological list
Use this to show the user a history of their past conversations.
Endpoint:
POST /memori/v2/UserChatLogsByTokenPagedPayload Parameters (
ChatLogFilters):
loginToken
String
User authentication token.
memoriID
String
Unique Memori ID (Engine).
from
Number
Starting index for pagination.
howMany
Number
Number of items to retrieve.
dateFrom / dateTo
String
Time range (format yyyyMMddHHmmssfff).
minimumMessagesPerChat
Number
(Optional) Minimum number of messages to include in the chat.
showChatsWithNoHistory
Boolean
(Optional) Include sessions that were opened but have no messages.
2. Parsing the response (JSON)
Regardless of which endpoint you use, the log structure follows this schema:
UI Integration: use
inbound: truefor user messages andinbound: falsefor assistant messages.
3. Opening a new session (resumption)
Once you've identified the conversation to continue, you need to open a new working session by injecting the past context.
Endpoint: POST /memori/v2/Session
Continuation options
In the request body, you can choose one of the two anchor parameters:
continueFromChatLogID: use the log block ID obtained in step 1.continueFromSessionID: use the previous session ID.
The session lasts 5 minutes.
Example JSON Body:
Result: the backend will return a new sessionID. From this point on, all subsequent messages must use this new ID.
Technical notes
ID targeting: the
chatLogIDidentifies the entire conversation snapshot. Never pass the ID of an individual message (line) in the continuation field.Context variables: use
initialContextVarsto pass data such as the language or current URL path; these help the engine provide contextual responses from the very first message of the resumed session.Client SDK: for strong typing of
ChatLogFiltersparameters, we recommend using the official@memori.ai/memori-api-clientpackage.
Benefits
Continuity of experience: users can pick up interrupted conversations where they left off;
Context retention: the Agent remembers information from the previous conversation;
Automatic handling: AIsuru automatically manages expired or invalid sessions;
Flexibility: compatible with all layouts and configurations.
Last updated