frontend_rpc calls back into the customer’s own web page. The operation names a
handler your page registered, sends it a payload, waits for its answer, and can
publish fields out of that answer like any other data operation.
It is what makes a web call more than audio: the agent can fill in the form the
caller is looking at, highlight the product they asked about, navigate the page,
or read something only the browser knows.
The configuration
Like
http and code, it also carries silent, publish_fields and
background_execution — it is one of the three kinds that produce a result.
The envelope
The platform sends one RPC method to the browser,talqing.frontend_rpc,
carrying a JSON envelope:
envelope.method to
whichever handler you registered under that name. You never register
talqing.frontend_rpc yourself.
Registering handlers in your page
useTalqingRpcHandlers from @talqing/sdk/browser takes a map of handler name
to handler. Each handler receives the payload as a JSON string and must
return a string.
useTalqingFrontendRpcs() is the other half of the pair: it registers a
catch-all handler that records the most recent payload per method and hands them
back as { actions, clear }. Useful for a debug panel while you are building —
it answers every call with "ok" and does nothing else.
Reading the answer back
Whatever the handler returns is parsed as JSON and becomes the operation’s result. A handler that returns a plain string that is not JSON is wrapped as{"result": "<the string>"}, so a bare "ok" is still addressable.
publish_fields
resolve.
When it fails
All of them are ordinary operation failures, so
on_error decides what happens
next: abort (the default) ends the tool with the agent’s graceful apology,
continue moves on to the next operation. For anything cosmetic — a highlight, a
scroll — on_error: "continue" is usually right: a caller should not be told the
tool failed because a page element had moved.
A registered handler that throws still returns a response; the operation
failing is the platform passing that failure on. Handle what you can inside the
handler and return a JSON answer describing it, rather than throwing, if the tree
should branch on it.
Fire and forget
background_execution: true detaches the operation. Nothing waits for the
browser, nothing is published, and any failure only reaches the logs. Use it for
one-way UI effects where the tree has no reason to know the outcome:
background_execution and publish_fields on the same operation is refused at
publish — a detached operation has no response to publish out of.
Worked example: filling a form the caller is looking at
The agent collects the details in conversation, writes them into the page, and confirms.In a test run a
frontend_rpc is simulated:
there is no browser attached to a test, so the step reports the method and the
resolved payload rather than calling anyone. That is enough to check your
templating; testing the handler itself means placing a web call.Next
Web call features
Frontend actions in context, with images, screen share and userdata.
Browser SDK
useTalqingRpcHandlers and every other hook, with signatures.Templating and data
Templating the payload, and publishing out of the answer.