1
Create a draft agent
Start by sending a
POST /api/v1/agents request with at minimum a title and a questions array. The API returns a new agent in draft state along with its agent_id, which you’ll use in every subsequent request.2
Map each field to a question type
Every question needs a
response_type that tells FormBharo how to parse and store the caller’s spoken answer. Choose the type that matches the original form field.For
single-select and multi-select, pass options as an array of strings. The agent reads the list aloud and maps the caller’s answer to the closest matching option.For number, omit number_format if the caller might say either integers or decimals; set it to "integer" or "decimal" when you know the expected format.3
Add scripts
Scripts give the agent its opening and closing lines. Set them inside a
scripts object on the agent body.scripts.intro— What the agent says at the very start of the call, before the first question. Use this to greet the caller and explain the purpose of the call.scripts.outro— What the agent says when all required questions have been answered and the call is complete.scripts.outro_incomplete— What the agent says when the call ends before all questions are answered (for example, the caller hangs up early).
You cannot set
outro_incomplete without also setting outro. Both must be present if you want to customise the incomplete ending.4
Add conditional branches
Branches let you skip or show groups of questions based on a caller’s earlier answer. The flow works in two parts:Use
- Declare the branch — add an entry to the top-level
branchesarray. Give it a uniqueidand aconditionthat references a questionidand a rule. - Tag questions — set
branch_idon every question that belongs to the branch. Those questions are only asked if the condition evaluates totrueat runtime.
present takes priority over equals. If both are set on the same condition, present is evaluated and equals is ignored.equals to branch on a specific value (for example, only proceed if the caller answered “yes”). Use present to branch whenever the caller gave any answer at all, regardless of what it was.5
Configure screening
Use Screened-out calls appear in analytics separately from fully completed calls, so you can track the size of the disqualified cohort without it inflating your failure rate.
end_call_values to end a call early when a caller gives a disqualifying answer. Supply an array of strings; if the agent records any of those exact values, it ends the call immediately and marks the conversation screened_out. Screened-out calls count as successes, not failures.6
Publish
When your agent is ready, publish it with
PUT /api/v1/agents/{agent_id}. Send the complete agent body — not just the changed fields — as the request body. The API validates the configuration and returns the published agent on success.Preview changes before saving
Before you publish a new version, you can review exactly what will change by callingPOST /api/v1/agents/{agent_id}/diff-preview with the proposed agent body. The response contains an array of diff lines, each with a type field:
Use this endpoint in CI pipelines or review tools to catch unintended changes before they reach a live agent.
curl