A2A Setup
Every NxisAI agent is wired to your page the same way. You host three things on your own origin, and the on-page agent writes the client:
- The agents: each one an A2A 1.0 endpoint and an Agent Card.
- A relay at
/api/handoff, which holds the credentials and the list of targets, and is the only thing the page talks to. - The page config:
agent.handoff, naming the targets the visitor can be handed to.
A target's URL and credential are never in the page. The browser knows a target by its name and label only.
The agent-handoff skill writes the relay, and each agent's skill adds its own target to it. See the Agent Skills Library.
The agent endpoint and card
Each agent mounts two routes on your origin:
| Agent | A2A endpoint (relay only) | Agent Card |
|---|---|---|
| Support Agent | POST /a2a/support | GET /a2a/support/agent-card.json |
| Quote Agent | POST /a2a/quote | GET /a2a/quote/agent-card.json |
| Booking Agent | POST /a2a/booking | GET /a2a/booking/agent-card.json |
The endpoint refuses any request without the relay's credential (403) and any body over 64 KB (413). Serve a card at /.well-known/agent-card.json as well only if no other agent on your site already claims that path.
The card tells the relay how to reach the agent. A trimmed example:
{
"name": "Ridgeline Help",
"description": "Answers questions about Ridgeline Air's products from its help content.",
"version": "1.0.0",
"provider": { "organization": "Ridgeline Air", "url": "https://ridgeline.example" },
"supportedInterfaces": [
{ "url": "https://ridgeline.example/a2a/support", "protocolBinding": "JSONRPC", "protocolVersion": "1.0" }
],
"capabilities": {
"streaming": true,
"pushNotifications": false,
"extensions": [{ "uri": "https://nxis.ai/a2a/handoff/v1", "required": false }]
},
"securitySchemes": {
"relay": { "httpAuthSecurityScheme": { "scheme": "Bearer" } }
},
"securityRequirements": [{ "schemes": { "relay": { "list": [] } } }]
}
supportedInterfacesmust listJSONRPCwithprotocolVersion"1.0", the A2A version the on-page agent speaks. Itsurlis your public origin, not an internal address (on a container, a Function URL or a*.run.appaddress, set the public origin explicitly).capabilities.streamingistrue, so replies arrive as the agent writes them.extensionsdeclares the NxisAI handoff extension,https://nxis.ai/a2a/handoff/v1: the envelope, answer cards, feedback and hand-back parts.securitySchemessays the agent expects a bearer token, which only the relay holds.
Name the agent for your business ("Ridgeline Help", "Ridgeline Quotes"), and use the same name in the card, the relay's label and the page's label.
The relay
One endpoint on your origin, at /api/handoff:
| Request | What it does |
|---|---|
GET /api/handoff | Lists the targets it will forward to, each with available (and, for a person, hours and queue). The on-page agent offers only targets listed here as available. |
POST /api/handoff/<name> | An A2A JSON-RPC request, forwarded to that target. Only SendMessage, SendStreamingMessage, GetTask, CancelTask and SubscribeToTask are accepted. |
POST /api/handoff-push | Push notifications from person targets, so a reply reaches a visitor who has left. Kept outside the visitor rate limit. |
Its targets are an allowlist in your server code. Each agent's skill adds one entry:
{ name: 'support', kind: 'agent', label: 'Ridgeline Help',
description: 'answers questions about our products and services from our own help content, with sources',
endpoint: '/a2a/support',
credential: () => ({ Authorization: `Bearer ${process.env.A2A_RELAY_TOKEN}` }),
transcript: false, push: false,
availability: supportAvailability }
| Field | Meaning |
|---|---|
name | Lower case. The key the page and the relay share |
kind | 'agent' or 'person' |
label, description | What the visitor reads, and what the model uses to pick a target |
endpoint | The agent's A2A URL: a path on the same server, or an absolute URL when the agent runs as a separate service |
credential | Reads the relay's token from a server-side secret |
transcript | Whether the visitor's last turns may go to the target. Keep false for the NxisAI agents |
push | Whether the target posts push notifications. false for the NxisAI agents |
availability | Whether the target can take a conversation now. Each agent's skill writes this check, for example "a model key is configured" or the agent's health check |
The relay must, on every request:
- Check the origin. A request from an origin not in
allowedOriginsgets 403. - Rate-limit visitors. Over-rate requests get 429 with
Retry-After. The reference limit is 60 requests a minute per visitor. - Cap bodies at 64 KB (413).
- Resolve the target from its own list. An unknown name is 404, and a URL in the request is never followed.
- Tie each task to its browser. The first message answers with a
Nxis-Handoff-Keyheader, and every later call about that task must carry it back, or it's refused with 403. One visitor can't read or cancel another's handoff by guessing a task id. - Keep a record of each handoff: the target, the task, what was shared and any contact details given. Records expire after 30 days in the reference relay.
The handoff targets on the page
Where your site mounts <nxis-agent>, name the targets the relay lists:
const agent = document.querySelector('nxis-agent');
agent.handoff = {
relay: '/api/handoff',
targets: {
support: { kind: 'agent', label: 'Ridgeline Help',
description: 'answers how-to and product questions from our help content, with sources' },
quote: { kind: 'agent', label: 'Ridgeline Quotes',
description: 'takes a quote or estimate request in conversation and sends it',
takes: ['quote_form'] },
booking: { kind: 'agent', label: 'Ridgeline Booking',
description: 'books a visit in conversation, from the free times on the calendar',
takes: ['book_a_visit'] },
team: { kind: 'person', label: 'Our team', description: 'a person at the office' },
},
};
| Field | Meaning |
|---|---|
kind | 'agent' or 'person'. Agents are offered through the transfer_to_agent tool, people through talk_to_a_person |
label | What the visitor reads: "You're talking with Ridgeline Help" |
description | Optional. What the target handles, so the model picks the right one |
takes | Optional. Form tools this target handles in their place, such as ['quote_form'] or ['book_a_visit']. See Targets that take a form |
A target is offered only when both the page and the relay name it. The page decides what the visitor sees; the relay decides what's reachable. Availability, hours and transcript sharing come from the relay at runtime, not from this config.
Each agent also adds a few lines to your system prompt, telling the on-page model when to call transfer_to_agent with its name. They're on each agent's page. If you route between specialist agents with agent.agents, transfer_to_agent has to be in the slice that handles that work, and talk_to_a_person in every slice.
Targets that take a form
A prompt line alone doesn't route requests away from a form: asked "Get a quote from McManus Electric", the model sees a tool named for exactly that and calls it. With takes, while the relay lists the target as available:
- the model isn't offered those form tools (the page's own, and the site-wide
…_anywherecopy); - a call to one anyway becomes the handoff, which the visitor confirms with Send;
- a NxisAI app link to the form (
?nxis_handoff=<the form's action @id>) starts the handoff instead; - a
resolvedhand-back is reported as the form sent, for your conversion analytics.
Anything short of a clear "available" (the relay down or slower than 1.5 s, the target away) leaves the form exactly as it was. Don't name a form tool in your system prompt, even as a fallback: a tool the prompt names gets called.
Secrets: what the host keeps
Every secret lives in your host's secret store. Never in the page, never in a public (VITE_- or NEXT_PUBLIC_-style) variable, never in a file you commit.
| Secret or setting | Used by | What it is |
|---|---|---|
A2A_RELAY_TOKEN | The relay and every agent | The bearer token the relay sends and the agent checks. Needed when the relay and the agent run as separate processes; when they share one, a fresh token per start is enough. There's no default: unset, nothing can call the agent |
ANTHROPIC_API_KEY | Each agent | Your model key. The agent calls the model server to server, billed to your account. Without it, the relay lists the agent as unavailable |
SUPPORT_MCP_ENDPOINT | Support Agent | Your site's MCP server URL, fixed server-side. Not a secret, but never taken from a request |
SUPPORT_GAP_KEY | Support Agent | A site-scoped key that can only report content gaps. See Content gaps |
SUPPORT_PROVISIONING_ENDPOINT | Support Agent | Where gap reports go. Kept server-side beside the gap key |
SUPPORT_TURN_REF_SECRET | Support Agent | The secret that question keys and turn references are made with. See What stays on your server. 32 characters or more, never sent anywhere. Without it, no gap reports are sent |
QUOTE_SINK_URL, NXIS_WEBHOOK_SIGNING_SECRET | Quote Agent | When your quote form posts to a webhook: its URL, fixed server-side, and the secret the agent signs each post with |
BOOKING_AVAILABILITY_URL | Booking Agent | Your free-slot endpoint, fixed server-side. Not a secret, but never taken from a request. Without it, the relay lists the agent as unavailable |
BOOKING_AVAILABILITY_TOKEN | Booking Agent | Optional. The bearer token your free-slot endpoint expects |
BOOKING_SINK_URL, NXIS_WEBHOOK_SIGNING_SECRET | Booking Agent | When your booking form posts to a webhook: its URL, fixed server-side, and the secret the agent signs each post with |
BOOKING_EXAMPLE_CALENDAR | Booking Agent | Local development only. true uses an in-memory example calendar instead of yours. Never set it on a live site |
Generate tokens and secrets with a cryptographic source, for example openssl rand -hex 32, and pipe them straight into your host's secret command, such as <HOST_SECRET_COMMAND> A2A_RELAY_TOKEN <RELAY_TOKEN>, so they never appear in a chat or a terminal log.
Origins and link-origins
Two lists of origins matter, and they do different jobs:
- The relay's
allowedOrigins: the origins the page may call the relay from. List full origins, scheme and port included, exactly as a browser sends them: production, plus each local origin you develop on. Every one must also be a host your JS tag token allows, or half the agent works where the other half doesn't. - The element's
link-originsattribute: other origins an agent's reply may link to, besides your page's own. A link to any other origin stays as plain text.
<nxis-agent link-origins="https://help.example.com https://www.youtube.com"></nxis-agent>
Links to another origin must be https, open in a new tab with no referrer, and a link to another page of your own site keeps the conversation. javascript:, data: and addresses with credentials never become links. A cited video's Watch may also link to YouTube or Vimeo. link-origins also decides where the on-page agent may open a page without asking first; see Agent Guardrails.
The confirmation step
Before a handoff, the visitor sees an action card naming the target, with the summary that will go and anything else shared, and presses Send. A handoff is always treated as the highest risk tier, so it's always confirmed, and the visitor's press approves that one handoff only. Agent Guardrails explains the tiers and approvals.
An agent that writes (Quote, Booking) asks for a second, separate confirmation inside its own conversation: a summary written by code from the checked values, and a plain "yes" as the visitor's next message. "Yes, but change the email" is a change, not a yes. The model never decides that the visitor agreed.
Hand-backs
An agent ends with a hand-back, { handoff: 'handback', outcome, note, references? }:
outcome | Meaning | The on-page agent |
|---|---|---|
resolved | The job is done | Carries on from the note, and shows the references ("Your quote reference is RR-4KQ7M2XH") |
transferred | The visitor wants something this agent doesn't do: a person, a quote, a booking | Carries on as if the visitor had asked it, following your prompt lines |
unresolved | It couldn't finish, for example an emergency where the visitor should phone | Shows the note, and takes over again |
The hand-back note is the only thing from the agent that reaches the on-page model, as its own note. Everything else the agent said is shown to the visitor as data, never treated as instructions, and never runs a tool. The visitor can also leave at any time with Back to the assistant.
Answer cards and feedback
The envelope tells the agent what your page can draw: ui: { cards: 1, feedback: 1 }.
- Cards. An agent can send the records behind an answer as cards beside its reply: an FAQ, how-to or article as a readable card (Read, Their page), a video as a media card (Watch), a team member as a profile card. Cards are copied from data, drawn as text, never as markup, and never carry an action button. A record already shown in the conversation is drawn as a compact row instead.
- Feedback. Every answer that carries an
answerIdgets two icon buttons, Helpful and Not helpful (thumbs up and thumbs down). Each shows an outline icon until pressed, then a solid one. One vote per answer: the chosen button stays pressed and both are disabled, across reloads, and they're disabled when the agent's task is over. A vote goes back to the agent on the same task as afeedbackpart. It isn't drawn as a message and never reaches the on-page model.
To send a vote from a UI of your own, use HandoffController.feedback(conversationId, answerId, value) with value 'up' or 'down'. It resolves true when the relay took it, and false when there's no open task, the answer already has a vote, or the relay refused it.
Host profiles
Each skill finds your host from the project and uses a host profile for the things that differ between hosts: where state lives, where secrets live, and how long a response may run. With many instances, an agent's state has to be in a store every request sees, or a follow-up lands on an instance that never saw the conversation. For a host with no profile, the skill asks you these questions instead.
| Host | Relay | Support Agent keeps | Quote Agent keeps | Booking Agent keeps | Secrets |
|---|---|---|---|---|---|
| Netlify | Netlify Blobs, strong consistency | Tasks and context in Netlify Blobs. Gap questions and reported turns in Netlify Blobs, or your own database | Tasks, progress and the submit claim in Netlify Blobs | Tasks, progress and the booking claim in Netlify Blobs, which never expire: an abandoned conversation stays until the store is cleared | Netlify environment variables |
| Vite (Node, for development) | A JSON file per record in a git-ignored folder | Memory; gap questions and reported turns in a development file | Memory | Memory | .env, git-ignored |
| Docker | Node relay. One process: files; more: a shared store such as Redis | Memory, so one replica. Gap questions and reported turns in a file on a volume | Memory on one replica; Redis for more, with the claim as a conditional set | Memory on one replica; Redis for more (a day), with the claim as a conditional set | .env.local, git-ignored |
| Cloud Run | Node relay, with a shared store every instance sees | Firestore, with a TTL for gap questions and reported turns | Firestore, with the claim as a conditional create | Firestore (a day), with the claim as a conditional create | Secret Manager |
| Cloudflare Workers | No profile yet | A Durable Object per task. Gap questions and reported turns in Workers KV | A Durable Object per task, holding the task, progress and claim | A Durable Object per task, holding the task, progress and claim (30 days after last use) | wrangler secret put |
| AWS Lambda | No profile yet | No profile yet | DynamoDB, with the claim as a conditional put | DynamoDB (7 days), with the claim as a conditional put | SSM Parameter Store, SecureString |
Notes that apply on every host:
- Profiles are drafts unless the skill says otherwise. The relay's Netlify profile is verified in production. The skill tells you which profile it's using and its status.
- The submit claim is how the Quote and Booking Agents send once: the task is claimed with a conditional write before the quote destination or booking sink is called, so a retry, a second instance or a repeated "yes" never sends again. If the store is unreachable, it refuses to send rather than risk a second submission.
- Separate services. When an agent runs as its own service (Docker, Cloud Run, Workers, Lambda), the relay target's
endpointis the agent's absolute URL, and itsavailabilityreads the agent's health check. Route only the A2A endpoint and the card paths through your site; keep the health check off the public internet. - Serverless time limits. A turn takes a few seconds. On hosts that can cut a response off, the agent fails a task left "working" the next time it's read, rather than leaving the visitor waiting. Work after the reply (the Support Agent's gap reports) is kept alive past the response.
- Cloud Run. The relay's bearer token travels in
Authorization, which Cloud Run's IAM check would otherwise claim, so the service runs with the invoker IAM check off and refuses anything without the token itself.
Related
- Agents overview: what each agent does, and what leaves the page
- On-Page Agent: the client half of the handoff
- Agent Protocols and Standards: MCP, WebMCP and the other standards a NxisAI site speaks
- A2A 1.0 specification