Hosted agent experiences
Share durable agent and assessment links with reconnect, questions, document upload, safe activity, and completion UI.
Overview
The hosted routes provide customer-facing durable experiences without requiring you to build a frontend. Both routes restore server state from cid, resolve supported client tools, expose Continue after interruption, and become read-only after permanent completion.
Use /agent for general agent workflows and document collection. Use /assessment for a focused question-and-answer experience.
Getting started
Start with the deployed assistant ID:
https://chat.amarsia.com/agent/YOUR_DEPLOYMENT_ID
https://chat.amarsia.com/assessment/YOUR_DEPLOYMENT_IDBoth routes understand:
| Parameter | Meaning |
|---|---|
tid | Trigger ID that prepares the first content and variables |
cid | Conversation ID that reopens durable state |
https://chat.amarsia.com/agent/YOUR_DEPLOYMENT_ID?tid=TRIGGER_ID
https://chat.amarsia.com/assessment/YOUR_DEPLOYMENT_ID?cid=CONVERSATION_IDAfter a trigger starts a conversation, the route adds cid to the current URL. Keep that resulting URL for refresh, return visits, or another device.
Configuration
Configure the assistant under Tools & Knowledge Base before sharing a route:
| Setting | /agent | /assessment |
|---|---|---|
ask_user | Structured question card | Current structured question card |
upload_document | Uploads one file, or up to max_files when multiple is enabled | No assessment UI |
| Custom client tool | Shows that a capable custom client is required | No custom-tool UI |
| Allow conversation completion | Read-only completed state | Read-only completed state |
| Trigger required | Optional; blocks direct start when enabled | Optional; blocks direct start when enabled |
Configure hosted ask_user and upload_document flows as always, including trigger links opened later. Use when_connected for custom SDK clients that explicitly advertise the matching capability.
Examples
Email a document request
Configure upload_document as always, then create a trigger:
import { amarsia } from "@amarsia/sdk"
const deploymentId = process.env.AMARSIA_DEPLOYMENT_ID!
const client = amarsia.init({
apiKey: process.env.AMARSIA_API_KEY!,
deploymentId,
})
const trigger = await client.trigger.create({
content: [{ type: "text", text: "Request the signed service agreement." }],
variables: { CUSTOMER_ID: "cus_123" },
uiSurface: "agent",
ttlHours: 72,
})
console.log(`https://chat.amarsia.com/agent/${deploymentId}?tid=${trigger.id}`)Put the printed link into your email provider. When the recipient opens it, /agent can upload the selected document and resolve the same pending run.
Recover an assessment
Create a trigger with uiSurface: "assessment" and share:
https://chat.amarsia.com/assessment/YOUR_DEPLOYMENT_ID?tid=TRIGGER_IDThe assessment writes cid after start. Reopening the resulting URL restores persisted assistant messages and the current unresolved ask_user call instead of starting again.
Continue an interrupted turn
If a client result was accepted but in-process continuation was interrupted, the hosted UI exposes Continue when the conversation is active and idle. Continue starts a new agent turn using stored conversation history; it does not replay the accepted result.
Hosted behavior
The /agent route:
- Shows actual user and assistant messages, excluding synthetic Start and Continue prompts.
- Shows allowlisted progress types and tool names with safe status summaries.
- Renders the current
ask_userorupload_documentcard. - Leaves unknown custom tools pending for a capable custom client.
The /assessment route:
- Shows assistant messages only.
- Renders only the current
ask_usercall. - Hides general activity and document-upload UI.
Both routes use SDK-managed refresh, stop local refresh when the page closes, disable writes after completion, and preserve server state for the next open.
Security
Enable Trigger required when only prepared sessions should start. Trigger expiry controls an unused trigger; after use, cid restores the linked conversation.
Configure authentication and origin allowlists for your deployment. Treat URLs containing tid or cid as application data: send them only to intended recipients and avoid analytics that capture full query strings.