Skip to main content

Deploying agent and AI Chat

There are two ways to deploy AI chat in your front end:
  1. iFrame Embedding
  2. Native React Component Embedding 🔒
To embed an Application Space for a specific user, use the following iFrame:
<iframe
  src={`https://ai-hub.upsolve.ai/share/application/${applicationId}?jwt=${projectUserToken}`}
  width="100%"
  height="800"
  style={{ border: "none" }}
/>
  • 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

ParameterTypeRequiredDescription
jwtstringYesProject user token for authentication
themelight | darkNoVisual theme
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:
"use client";
import React from "react";
import { useUser } from "@clerk/nextjs";

const AIChatInterface: React.FC = () => {
  // Get the user information from Clerk and extract the Upsolve token from the metadata
  const { user } = useUser();
  const upsolveToken = user?.publicMetadata?.["upsolveToken"];
  const agentId = "your-agent-id"; // Replace with your agent ID

  // Embed the chat component into your app
  return (
    <>
      {upsolveToken != null && typeof upsolveToken === "string" && (
        <iframe
          id={agentId}
          title="AI Chat"
          width="100%"
          height="800"
          style={{ border: "none" }}
          src={`https://ai-hub.upsolve.ai/share/chat/${agentId}?jwt=${upsolveToken}&theme=light`}
        />
      )}
    </>
  );
};

export default AIChatInterface;
For organizations migrated to hub2.5, use the ai-hub.upsolve.ai URL format shown above. Legacy URLs (hub.upsolve.ai/share/dashboard/... and hub.upsolve.ai/share/chat/...) continue to work and will automatically forward to the new experience.

Dashboard Query Parameters

The dashboard iframe supports the following query parameters:
ParameterTypeRequiredDescription
jwtstringYesTenant JWT for authentication
themelight | darkNoVisual theme
versionnumberNoLock to a specific dashboard version (defaults to latest)
hideHeaderbooleanNoHide the header UI
hideDownloadButtonbooleanNoHide the download button
themeConfigsJSON stringNoCustom theme configuration
dbAuthTokenstringNoDatabase authentication token for RLS (see RLS section)
filter_{key}anyNoControlled filter values (e.g., filter_region=US)

Version Locking

You can lock an embedded dashboard to a specific version using the version parameter. This ensures that the dashboard renders with a specific configuration, even if newer versions are published.
<iframe
  id="c5da5cb3-fedb-4656-9170-0cc65c9db29a"
  title="Example Dashboard"
  width="1000"
  height="1000"
  src="https://ai-hub.upsolve.ai/share/dashboard/c5da5cb3-fedb-4656-9170-0cc65c9db29a?theme=light&jwt=<upsolveToken>&version=5"
/>
Version locking is useful when: - You want to maintain consistency across deployments - You need time to test new dashboard versions before deploying them - Different customers should see different versions of the same dashboard

Chat Query Parameters

The chat iframe supports the following query parameters:
ParameterTypeRequiredDescription
jwtstringYesProject user JWT for authentication
promptstringNoInitial prompt — auto-sent when the chat loads
themelight | darkNoVisual theme
placeholderOverridesJSON stringNoCustomize UI text (input placeholder, assistant name, disclaimer, etc.). See schema below
exampleQuestionsJSON stringNoArray of starter questions shown on the welcome screen before the user sends their first message

placeholderOverrides Schema

{
  "userName": "string",
  "assistantName": "string",
  "inputPlaceholder": "string",
  "thinkingPlaceholder": "string",
  "disclaimerText": "string"
}
All fields are optional. For example, to customize the input placeholder and disclaimer:
?placeholderOverrides={"inputPlaceholder":"Ask about your data...","disclaimerText":"Results may be approximate."}

exampleQuestions Example

?exampleQuestions=["What were our top sales last quarter?","Show revenue by region"]

Example with Initial Prompt

const AIChatWithPrompt: React.FC = () => {
  const { user } = useUser();
  const upsolveToken = user?.publicMetadata?.["upsolveToken"];
  const agentId = "your-agent-id";
  const initialPrompt = "What were our top sales last quarter?";

  return (
    <iframe
      src={`https://ai-hub.upsolve.ai/share/chat/${agentId}?jwt=${upsolveToken}&prompt=${encodeURIComponent(
        initialPrompt
      )}&theme=dark`}
      width="100%"
      height="800"
      style={{ border: "none" }}
    />
  );
};

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.
// Example: Token change triggers iframe reload and session reset
const AIChatInterface: React.FC = () => {
  const { user } = useUser();
  const upsolveToken = user?.publicMetadata?.["upsolveToken"];

  // When upsolveToken changes, the chat session resets
  return (
    <iframe
      src={`https://ai-hub.upsolve.ai/share/chat/abc?jwt=${upsolveToken}`}
      // ↑ Changing upsolveToken resets the entire conversation
    />
  );
};
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