frontend_rpc calls a handler your web page registered, sends it a payload,
waits for its answer, and can publish fields out of that answer. Use it to let
the agent fill in a form, highlight a product, navigate the page, or read state
only the browser has. It works on web calls only.
useTalqingRpcHandlers from
@talqing/react inside your Talqing call context:
Config
Like
http and code, it takes silent, publish_fields and
background_execution.
The contract with the page
The agent sends one RPC method,talqing.frontend_rpc, with the envelope
{"method": "...", "payload": ...}. The browser SDK registers that method when
you call useTalqingRpcHandlers and dispatches on method; you never register
talqing.frontend_rpc yourself.
- A handler receives
{ payload }, wherepayloadis the JSON-encoded payload string, and must return a string. - The answer is parsed as JSON and becomes the operation’s result. A string that
is not JSON becomes
{"result": "<the string>"}, so"ok"is still publishable. - A
"*"key catches every method with no handler of its own and receives the whole envelope as its payload. - Throw
TalqingRpcError(code, message)from@talqing/clientto choose the error code the agent sees.
useTalqingFrontendRpcs() registers a catch-all that records the latest payload
per method and answers "ok", for a debug panel while building.
When it fails
Each of these fails the operation, andon_error decides what happens next.
For cosmetic effects like a highlight, on_error: "continue" is usually right.
None of these is caught at publish, because one tool can be attached to a web
agent and a phone agent. If the tree should branch on a handler’s outcome, return
it in the answer instead of throwing.
For one-way UI effects,
background_execution: true sends the call without
waiting; nothing is published.
In a test run the operation is
simulated and reports the method and resolved payload. Testing the handler itself
needs a web call.
Next
Web call features
Frontend actions alongside images and screen share.
React SDK
useTalqingRpcHandlers and the other hooks.