Skip to main content

Deploying agent and AI Chat

Deploy AI chat in your frontend by embedding it as an iFrame. To embed an Application Space for a specific user, use the following iFrame:
  • applicationId — found in your hub2 application settings, or in the URL when viewing the application: /projects/{projectId}/applications/{applicationId}
  • projectUserToken — a short-lived JWT obtained from your backend via POST /v1/api/projects/user-token (see Backend Setup)
Token expiry: Project user tokens expire after 1 hour by default. Replacing the jwt query parameter will reload the iFrame. To re-authenticate without a full reload, recreate the iFrame element programmatically.

Application Query Parameters

Only compatible with project users — the /share/application/ route requires a project user JWT obtained from POST /v1/api/projects/user-token. Legacy tenant JWTs are not supported for application embeds.

Deploying Chat via iFrame

You’ll need to get the JWT for the current user and the agent ID to render the chat interface. The JWT is generated by following the steps in Backend Setup.

Getting the Agent ID

You can find your agent ID by visiting your agents at https://ai-hub.upsolve.ai/agents. The agent ID is visible in the URL when you click on an agent, or in the agent list view.
Agent ID Location
Authentication via JWT: Chat iframes use JWT tokens passed via query parameters for authentication, similar to dashboards. Users don’t need to be logged into the Hub - they just need a valid JWT token in the URL.
Important: Changing the JWT token in the iframe src will cause the browser to reload the entire iframe and reset the chat session. This happens automatically when:
  • The JWT expires and gets refreshed
  • User switches tenants/organizations
  • Tenant permissions are updated
Each iframe load starts a fresh chat session. Plan your token refresh strategy carefully to avoid interrupting active conversations.
Below is an example of deploying chat with JWT using Clerk middleware:

Deploying Chat via React SDK

For a more integrated experience, use the UpsolveChat React component from @upsolve-labs/sdk. This handles all rendering and chat interactions without needing to manage an iFrame manually.
  • agentId — your agent’s unique ID (see Getting the Agent ID above)
  • projectUserToken — a short-lived JWT obtained from your backend via POST /v1/api/projects/user-token (see Backend Setup)
The React SDK approach is recommended when you want tighter control over the chat component’s lifecycle and styling within your React application.

The agent Deploy tab in the Hub provides a built-in preview link generator so you can quickly test your agent as a specific project user — no backend integration required. How it works:
  1. Open your agent in the Hub and navigate to the Deploy tab.
  2. Select a project user from the dropdown (defaults to the currently active project user).
  3. Click Generate preview iframe link — this creates a 1-hour JWT token and produces a fully working chat URL.
  4. Open the URL in a browser or paste it into an iFrame to preview the agent experience for that user.
Preview links are for testing only. The generated token expires after 1 hour and should not be used in production. For production deployment, integrate the token generation into your backend as described in Backend Setup.

Chat Query Parameters

The chat iframe supports the following query parameters:

placeholderOverrides Schema

All fields are optional. For example, to customize the input placeholder and disclaimer:

exampleQuestions Example

Example with Initial Prompt

Understanding Session Reset on JWT Change

When the upsolveToken value changes, React re-renders the iframe with a new src URL. This causes the browser to completely reload the iframe and start a new chat session.
Common scenarios that trigger session reset:
  • Automatic token refresh (every hour)
  • User switches between tenants/organizations
  • User logs out and back in
  • Tenant permissions are updated
To preserve chat history across token refreshes, consider: 1. Implementing session persistence on your backend 2. Storing conversation history outside the iframe 3. Refreshing tokens during natural conversation breaks 4. Warning users before token expiration