Skip to main content

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:

  1. The agents: each one an A2A 1.0 endpoint and an Agent Card.
  2. A relay at /api/handoff, which holds the credentials and the list of targets, and is the only thing the page talks to.
  3. The page config: agent.handoff, naming the targets the visitor can be handed to.
A2A setupIn the visitor's browser, the visitor talks to the nxis-agent element. The element calls the relay at /api/handoff on the same origin. The relay keeps a record of each handoff and calls the Support, Quote and Booking agents over A2A 1.0 with its own credential. Target URLs and credentials never reach the browser.Visitor's browserYour originVisitor<nxis-agent>on your pagesameoriginRelay/api/handoffHandoff recordA2A 1.0Support Agent/a2a/supportQuote Agent/a2a/quoteBooking Agent/a2a/bookingeach with an Agent CardThe relay holds the credential and the target list. The browser knows each target by name only.

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:

AgentA2A endpoint (relay only)Agent Card
Support AgentPOST /a2a/supportGET /a2a/support/agent-card.json
Quote AgentPOST /a2a/quoteGET /a2a/quote/agent-card.json
Booking AgentPOST /a2a/bookingGET /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": [] } } }]
}
  • supportedInterfaces must list JSONRPC with protocolVersion "1.0", the A2A version the on-page agent speaks. Its url is your public origin, not an internal address (on a container, a Function URL or a *.run.app address, set the public origin explicitly).
  • capabilities.streaming is true, so replies arrive as the agent writes them.
  • extensions declares the NxisAI handoff extension, https://nxis.ai/a2a/handoff/v1: the envelope, answer cards, feedback and hand-back parts.
  • securitySchemes says 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:

RequestWhat it does
GET /api/handoffLists 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-pushPush 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 }
FieldMeaning
nameLower case. The key the page and the relay share
kind'agent' or 'person'
label, descriptionWhat the visitor reads, and what the model uses to pick a target
endpointThe agent's A2A URL: a path on the same server, or an absolute URL when the agent runs as a separate service
credentialReads the relay's token from a server-side secret
transcriptWhether the visitor's last turns may go to the target. Keep false for the NxisAI agents
pushWhether the target posts push notifications. false for the NxisAI agents
availabilityWhether 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 allowedOrigins gets 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-Key header, 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' },
},
};
FieldMeaning
kind'agent' or 'person'. Agents are offered through the transfer_to_agent tool, people through talk_to_a_person
labelWhat the visitor reads: "You're talking with Ridgeline Help"
descriptionOptional. What the target handles, so the model picks the right one
takesOptional. 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 …_anywhere copy);
  • 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 resolved hand-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 settingUsed byWhat it is
A2A_RELAY_TOKENThe relay and every agentThe 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_KEYEach agentYour 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_ENDPOINTSupport AgentYour site's MCP server URL, fixed server-side. Not a secret, but never taken from a request
SUPPORT_GAP_KEYSupport AgentA site-scoped key that can only report content gaps. See Content gaps
SUPPORT_PROVISIONING_ENDPOINTSupport AgentWhere gap reports go. Kept server-side beside the gap key
SUPPORT_TURN_REF_SECRETSupport AgentThe 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_SECRETQuote AgentWhen your quote form posts to a webhook: its URL, fixed server-side, and the secret the agent signs each post with
BOOKING_AVAILABILITY_URLBooking AgentYour 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_TOKENBooking AgentOptional. The bearer token your free-slot endpoint expects
BOOKING_SINK_URL, NXIS_WEBHOOK_SIGNING_SECRETBooking AgentWhen your booking form posts to a webhook: its URL, fixed server-side, and the secret the agent signs each post with
BOOKING_EXAMPLE_CALENDARBooking AgentLocal 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.

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-origins attribute: 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? }:

outcomeMeaningThe on-page agent
resolvedThe job is doneCarries on from the note, and shows the references ("Your quote reference is RR-4KQ7M2XH")
transferredThe visitor wants something this agent doesn't do: a person, a quote, a bookingCarries on as if the visitor had asked it, following your prompt lines
unresolvedIt couldn't finish, for example an emergency where the visitor should phoneShows 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 answerId gets 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 a feedback part. 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.

HostRelaySupport Agent keepsQuote Agent keepsBooking Agent keepsSecrets
NetlifyNetlify Blobs, strong consistencyTasks and context in Netlify Blobs. Gap questions and reported turns in Netlify Blobs, or your own databaseTasks, progress and the submit claim in Netlify BlobsTasks, progress and the booking claim in Netlify Blobs, which never expire: an abandoned conversation stays until the store is clearedNetlify environment variables
Vite (Node, for development)A JSON file per record in a git-ignored folderMemory; gap questions and reported turns in a development fileMemoryMemory.env, git-ignored
DockerNode relay. One process: files; more: a shared store such as RedisMemory, so one replica. Gap questions and reported turns in a file on a volumeMemory on one replica; Redis for more, with the claim as a conditional setMemory on one replica; Redis for more (a day), with the claim as a conditional set.env.local, git-ignored
Cloud RunNode relay, with a shared store every instance seesFirestore, with a TTL for gap questions and reported turnsFirestore, with the claim as a conditional createFirestore (a day), with the claim as a conditional createSecret Manager
Cloudflare WorkersNo profile yetA Durable Object per task. Gap questions and reported turns in Workers KVA Durable Object per task, holding the task, progress and claimA Durable Object per task, holding the task, progress and claim (30 days after last use)wrangler secret put
AWS LambdaNo profile yetNo profile yetDynamoDB, with the claim as a conditional putDynamoDB (7 days), with the claim as a conditional putSSM 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 endpoint is the agent's absolute URL, and its availability reads 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.