Before you start
You need two things: the agent ID for the agent you want to run, and the URL of your FormBharo server. Before the call begins, fetch the agent’s public profile withGET /api/v1/agents/{agent_id}/public. This route requires no API key, so you can call it safely from the browser. It returns the agent’s title, its questions list, and an agent_speaks_first flag — enough to render a form UI or a progress indicator before the audio connection is open.
curl
agent_speaks_first to decide whether to show a “waiting for agent” state or a push-to-talk prompt when the call first connects.
Run the call
1
Generate a conversation ID
Create a unique conversation ID in your browser before opening the connection. FormBharo uses whatever ID you provide — it does not generate one for you.Store this value — you’ll pass it to the WebRTC offer and use it later to poll for answers.
javascript
2
Open the audio connection
Send a
POST /offer request to start the WebRTC handshake. Note that this path is at the bare root of the server — it is not under /api/v1 — and it requires no API key.Send a JSON body with three fields:The response is a WebRTC SDP answer. Use it to complete the peer connection on the browser side.To exchange ICE candidates after the initial handshake, send them with
PATCH /offer.javascript
3
Read answers as they arrive
Poll
GET /api/v1/data/{agent_id}/{conversation_id} every two seconds or so to read answers as the agent collects them. This route requires no API key.- Before the first answer is written, the endpoint returns an empty object
{}. - Once the call is underway, it returns a
form_dataobject (keyed by question ID) and aform_statusstring.
javascript