YOUR_BRANCH_ID are not real values.
HMS platform checklist (end-to-end)
Any hospital / HMS vendor can follow this ordered list. Full request/response samples for eachuse_case are in Tenant webhook contract.
Phase 0 - Prerequisites
- HMS owns patients, hospitals/branches, doctors, slots, and bookings (source of truth).
- Ondial tenant can own inbound PSTN numbers via Public API purchase (when credits allow) or dashboard assign/purchase.
- HMS exposes one public HTTPS webhook URL (e.g.
https://api.your-hms.com/ondial). - Shared secret agreed (
YOUR_SHARED_SECRET) forAuthorization: Bearer …. - (API path) Ondial API key requested and approved (
ond_live_…).
Phase 1 - Build the webhook (standard contract)
Expose onePOST endpoint. Every body includes operation + use_case. Switch on use_case.
Minimum for appointments (any scope):
Required for
global scope only:
Optional features:
Example request your HMS receives:
- HTTPS in production; respond within timeout (default 8000 ms).
- Honor Bearer secret when configured.
- Use stable IDs from your DB (
branch_id/hospital_id/doctor_id/slot_id). - Hospital/doctor-scoped agents: Ondial may inject locked
branch_id/doctor_id- accept them. patient_lookupfailure → soft fail (call continues). Slots/book failure → hard fail (do not fake success).
Phase 2 - Wire the agent in Ondial
Pick one scope per phone number:
Dashboard path: Inbound → Healthcare → Integration type HMS Custom API → Base URL + secret → Appointments ON → scope + your IDs → Save → Sync doctors → Activate.
API path (HMS backend - recommended for SaaS):
GET /api/v1/credits- check balance before buyGET /api/v1/numbers/available- browse pool inventory with per-number costPOST /api/v1/numbers/purchase- buy when credits suffice (402 insufficient_creditsif not)GET /api/v1/numbers- confirm owned numbersGET /api/v1/companies- pickcompanyId(scopecompanies:read; create viaPOST /companiesif needed)GET /api/v1/knowledge-bases/documents- pickfileIds (scopeknowledge:read; upload viaPOST …/documentsif needed)GET /api/v1/voices?market=IN&language=hi-IN&tier=premium- pickvoices[i].selectedVoice(copy as-is)POST /api/v1/inbound-agents(scope +customApiBaseUrl+companyId+selectedKnowledgebases+selectedVoice+primaryLanguage; or omit voice for auto-default / usecopyVoiceFromAgentId)POST /api/v1/inbound-agents/{id}/sync-doctors(hospital/doctor only)POST /api/v1/inbound-agents/{id}/generate-scriptPOST /api/v1/inbound-agents/{id}/activatewith{ "activate": true }
hcBookingPath: custom_api automatically when scope + Custom API URL are set. If companyId is omitted, Ondial auto-picks the latest company.
Create example (hospital):
Phase 3 - Runtime (live call)
Phase 4 - Ongoing management
Phase 5 - Go-live verification
- Webhook reachable over HTTPS with Bearer auth.
- Sync doctors returns your real doctor list (hospital/doctor scopes).
- Test call produces
doctor_slotsthenbook_appointmentin HMS logs. - Booking ID exists in your HMS.
- Google Calendar is not required on this path.
Architecture
The voice agent never calls your HMS directly. It calls Ondial mid-call APIs; Ondial POSTs to your HTTPS webhook.What you get
One Ondial phone number = one scope. Buy or assign a number, then attach the scope. Reuse the same webhook URL on many numbers.
On a global number the voice agent supports both:
- Hospital → category → doctor → slots → book
- Category → doctor → hospital → slots → book
Setup in the dashboard
1
Own an Ondial number
Purchase via Public API (
GET /credits → GET /numbers/available → POST /numbers/purchase) or in the dashboard.2
Open inbound setup
Choose category Healthcare Reception. Features start off.
3
Pick integration type
Select HMS Custom API (not Google Calendar + CRM).
4
Connect your webhook
Enter your HTTPS Base URL and optional Bearer secret. Production must use
https://.5
Enable features and scope
Turn on Appointments. Choose scope:
global, hospital (your branch/org ID), or doctor (your branch + doctor ID). Optionally enable lab report / prescription inquiry and patient lookup.6
Save, sync, activate
Save the agent. For hospital/doctor scopes, click Sync doctors from HMS. Open Review & Launch and activate.
Setup via Public API (HMS admin)
1
Get an API key
Request API access. Use
Authorization: Bearer ond_live_… from your HMS backend.2
Own Ondial numbers
From your HMS backend:
GET /api/v1/credits → GET /api/v1/numbers/available → POST /api/v1/numbers/purchase (pool inventory; credits debited). Or purchase in the dashboard. Then GET /api/v1/numbers to list owned DIDs.3
Implement your webhook
Expose one HTTPS URL. Ondial POSTs
{ operation, use_case, ...fields }. See webhook contract.4
Create an inbound agent
Optionally
GET /api/v1/companies and GET /api/v1/knowledge-bases/documents to pick ids. Then POST /api/v1/inbound-agents with appointmentScope, Custom API URL, flags, and optionally companyId + selectedKnowledgebases: ["fileId", …]. Optional copyVoiceFromAgentId to copy voice/language from an existing agent. This sets Appointments ON and hcBookingPath: custom_api automatically. Agent starts inactive.5
Sync doctors (hospital / doctor only)
POST /api/v1/inbound-agents/{id}/sync-doctors. Global numbers skip this - catalogs are fetched live during the call.6
Generate script
POST /api/v1/inbound-agents/{id}/generate-script. Wait until inboundScriptStatus is ready (poll GET …/inbound-agents/{id}).7
Activate
POST /api/v1/inbound-agents/{id}/activate with { "activate": true }.Create examples
Global helpdesk numberHMS admin UX (your platform)
Hospital staff use your HMS admin UI only. Your backend calls Ondial with one tenant API key (ond_live_…). Never expose the API key to the browser.
Recommended screens
Server module (HMS codebase)
Store in HMS env (server-side only):ONDIAL_BASE_URL- e.g.https://dashboard.ondial.aiONDIAL_API_KEY-ond_live_…from Ondial API Access
branchId / doctorId on create.
Buy-number sequence
Purchase exampleCreate agent after purchase (all scopes)
UsephoneNumberId from purchase response or phoneNumber E.164 from GET /api/v1/numbers.
Global - no sync:
POST …/generate-script → POST …/activate.
Hospital - sync then script then activate:
Tenant webhook contract
Ondial POSTs JSON tocustomApiBaseUrl (the exact URL you configured - no path suffix is appended).
Requirements
- HTTPS in production
- Respond within your configured timeout (default 8000 ms; patient lookup often 5000 ms)
- When
customApiSecretis set, expectAuthorization: Bearer YOUR_SHARED_SECRET
branch_id (and doctor_id for doctor scope) on every Custom API payload when missing. Global never injects a configured hospital - the caller-selected hospital is sent as chosen on the call.
patient_lookup - read
Request:
{ "found": false }
category_list - list
Request: { "operation": "list", "use_case": "category_list" }
Response:
hospital_list - list
Request may include category_id and/or doctor_id filters.
doctor_list - list
Request may include branch_id, hospital_id, category_id, and/or doctor_id.
doctor_slots - list
Request:
book_appointment - write
Request:
record_id is also accepted as an alias for booking_id.
lab_report - read (optional feature)
When lab report inquiry is enabled on the agent:
{ "found": true, "row": { … } } or { "found": false }.
prescriptions - read (optional feature)
When prescription routing is enabled:
{ "found": true, "row": { … } } or { "found": false }.
Failures
patient_lookuptimeout or error → call still accepted (anonymous). Do not hang up.- Slots / book errors → return failure. Ondial must not confirm a booking your HMS rejected.
Validation
Related APIs
- Create inbound agent
- Update inbound agent
- Sync doctors
- List owned numbers
- Activate
- Inbound CRM lookup (dry-run read without a live call)
- List calls
- Credit transactions
- Manage webhooks
Usage & call analytics
Build a wallet + call-log UI the same way production CRMs do: webhooks for near-real-time, poll APIs for catch-up.Async billing (important)
Inbound voice flow:POST /api/inbound/validate→ session starts → Ondial may emitcall.inbound.startedPOST /api/inbound/call/end→ transcript saved →call.inbound.completedwithbillingStatus: pending(no credits yet)- Carrier hangup / signed inbound-billing → credits deducted once →
call.inbound.billed+credits.usage
GET /api/v1/credits/transactions.
call.inbound.billed / credits.usage and GET /api/v1/credits/transactions include fromNumber / toNumber (plus callerNumber / phoneNumber aliases), conversationId, and durationSeconds so wallet UIs can render From/To/DID without waiting for a separate calls merge. Prefer conversationId when joining to GET /api/v1/calls/{id} - callId may be a telephony UUID.
HMS checklist
- API key scopes:
calls:read,credits:read,webhooks:write; request opt-inanalytics:readandrecordings:readif needed. POST /api/v1/webhookswith events:call.inbound.started,call.inbound.completed,call.inbound.billed,call.inbound.analysis,call.outbound.status,call.outbound.billed,call.outbound.analysis,outbound.lead.created,outbound.lead.updated,credits.usage.- Verify
X-Ondial-Signature(HMAC-SHA256 of raw body). PreferX-Ondial-Idempotency-Keyfor dedupe. - Upsert local rows by
conversationId/callId+direction. On*.billed/credits.usage, update cost usingusageIdfor idempotency. Requeues create a newcallId- do not overwrite prior dials bycontactIdalone. - Poll
GET /api/v1/callsandGET /api/v1/credits/transactionsevery 5–15 minutes and on UI open. - Live board:
GET /api/v1/calls/active. - Aggregates:
GET /api/v1/analytics/calls?groupBy=day. - Recordings:
GET /api/v1/calls/{id}/recording(short-TTL signed URL). - Map each hospital/org → one Ondial account + API key.
POST /api/internal/tenant-webhooks/dispatch - see Ondial/docs/api-v1/OUTBOUND-TENANT-WEBHOOK-CONTRACT.md.
