Session Data Exit Point
Description
In some cases, authenticating data alone may not provide enough context for an AI interaction and you may want to integrate other user session data from your application. For example, you may want your Profound AI agent to know which customer the user is viewing, or what department they belong to.
This can be achieved by specifying an exit program that retrieves and injects additional user data at runtime. An exit program is a Node.js script that allows your application to securely pass and retrieve session-specific information (such as user identity, session ID, or other contextual values) between the client and server.
By setting up an exit program, developers can extend authentication beyond basic payloads, enabling Profound AI agents to access personalized context for each user session. This enhances the assistant’s ability to deliver tailored responses, automate workflows, and interact seamlessly with application data.
Benefits
Personalizes AI interactions based on user identity and session context.
Enables dynamic, secure data retrieval tied to active sessions.
Simplifies data sharing between your application and Profound AI agents.
Provides flexibility to integrate with existing authentication and user management systems.
How It Works
Setup Component | Description |
|---|---|
Client-side setup | The application passes session information to the AI agent using the profound.ai.startAgent({
agent: "my-assistant.agent.json",
data: () => ({
"sessionId": currentSessionId
})
}); |
Server-side exit program | The Node.js exit program receives the session data, retrieves the corresponding user details, and returns them to the agent. function sessionExitPoint(data) {
const sessionId = data.sessionId;
const identity = data.identity;
// logic to retrieve session data goes here
return myData;
}
exports.default = sessionExitPoint; |
Agent Instructions | Within Agent Instructions, session values can be referenced dynamically. Agent Instructions can access session data through the You are helping ${identity.name} work with customer information.
The current customer number is ${sessionData.customerNumber}. |
Routines | Session data can also be accessed programmatically in routines. To access |