Skip to content

Knowledge sync

Your system is the record. Push what the assistant should know (products, prices, services, branches, policies) as records, and push again whenever something changes. The assistant answers callers and chats from the latest version within seconds.

A record is one thing, identified by your own id within a source you name:

{
"external_id": "sku-1042",
"kind": "product",
"name": "Luna GPS Tracker",
"aliases": ["लुना जीपीएस", "luna tracker"],
"updated_at": "2026-10-07T10:00:00Z",
"facts": [
{ "relation": "price", "text": "Rs 12,999 including installation", "volatile": true },
{ "relation": "warranty", "text": "One year warranty on the device" },
{ "relation": "notes", "text": "Dealer margin 20%", "audience": "staff" }
],
"links": [{ "relation": "category", "to": "cat-trackers" }]
}
  • aliases: other names callers use, including Nepali spellings. The assistant also matches names that sound alike, so a misheard name still finds the record.
  • facts: what the assistant may say about it. audience is public (default), customers or staff. Staff facts are never told to callers.
  • volatile: the value changes often. The assistant says “as of” its date.
  • valid_from and valid_to: a fact that starts or ends on its own, such as an offer.
  • updated_at: when your system last changed the record. An older version never replaces a newer one, so out-of-order deliveries are safe.

PUT /v1/knowledge/sources/{source}/records/{external_id} upserts one record. POST /v1/knowledge/sources/{source}/records with {"records": [...]} upserts up to 500.

Terminal window
curl -X POST https://app.airfone.app/v1/knowledge/sources/shop/records \
-H "Authorization: Bearer $AIRFONE_KEY" -H "Content-Type: application/json" \
-d @records.json

Each record in a batch gets its own result: written, unchanged (the same content as last time), stale (older than what is stored) or error with a message. One bad record never blocks the others.

Pushing the same content again is a no-op, so a full nightly push is cheap. Every record is kept exactly as received, so each answer can be traced to what you sent.

DELETE /v1/knowledge/sources/{source}/records/{external_id} removes a record. The assistant stops using it at once. History is kept.

A record you push with "deleted": true, "is_deleted": true, "archived": true or a deleted_at time is treated the same way, so a soft delete in your system needs no extra call. Only external_id is needed for it.

GET /v1/knowledge/sources lists your sources with record counts and when each last received data.

If a record used to have a fact with a relation (say warranty) and a new push leaves it out, AirFone keeps the old fact and lists the relation under dropped in the result. Send it again, or delete the record if it really went away. Nothing disappears because a field was missing from one push.

POST /v1/knowledge/sources/{source}/rollback with {"since": "2026-10-09T08:00:00Z"} closes every fact that source wrote since then and brings back what they replaced. The reply says how many were closed and restored.

A fact with "variant": "customer:<contact id>" is that customer’s own price or terms. The assistant tells it only to that customer, calling from their own number, and it wins over the general price. Everyone else hears the general one.

Each organization can push up to 100,000 records an hour. Past that, pushes get 429 with rate_limited and how many minutes to wait.

Terminal window
npm i -g @airfone/connector
export AIRFONE_KEY=af_...
airfone knowledge push shop records.jsonl # a JSON array or JSON Lines
airfone knowledge delete shop sku-1042
airfone knowledge sources

push sends 500 records per request, retries rate limits and server errors, prints every failed record, and exits non-zero when any failed, so it fits a cron job or CI.

Use a secret API key with the knowledge:write scope. Requests count toward the key’s rate limit; a refused request gets 429 with Retry-After.

GET /v1/knowledge/ontology?templates=shop,clinic returns the kinds of things a business of that type usually has (product, doctor, room…), their usual facts (price, schedule…), how they link, and the shared shapes (sellable, bookable, located, contactable). Use those kind values in your records so screens and the assistant treat them alike. Any other kind is accepted too.

Templates: shop, clinic, hotel, salon, restaurant, isp, school, services, finance, government, office, nonprofit, community, agriculture. Leave templates out to get the one that fits the business (from the type it chose when it signed up), or pass templates=all.

Instead of pushing, AirFone can read a business’s website itself and keep it in sync. Every page of the site is read; links to other sites are not followed. Prices, tables, phone numbers, emails, opening hours and offers like “free delivery above Rs 2,000” become facts; the rest of the text stays searchable. No AI is used to read pages.

Terminal window
curl https://app.airfone.app/v1/knowledge/connections \
-H "Authorization: Bearer $AIRFONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"kind": "website", "url": "https://www.example.com", "schedule": "weekly", "audience": "public"}'
  • schedule: daily, weekly (default) or manual. audience: public (default), customers or staff.
  • Adding a site that is already connected returns the existing connection with "created": false.
  • GET /v1/knowledge/connections lists them with status, last and next sync, and failures.
  • POST /v1/knowledge/connections/:id/sync syncs now. Asked during a sync, it runs right after.
  • PATCH /v1/knowledge/connections/:id with status (active, paused), schedule, audience or name. A new audience applies at once to everything the site taught.
  • DELETE /v1/knowledge/connections/:id answers 202 at once; what the site taught stops answering and is removed in the background.
  • POST /v1/knowledge/connections/:id/rollback with {"since": "..."} undoes what syncs of that website taught since then.
  • GET /v1/knowledge/connections/:id/runs lists the last 50 syncs: when, pages seen, new, changed and gone, facts and passages learned, and any error.
  • GET /v1/knowledge/connections/:id/items?limit=100&after=<id> pages through what was read, with any error per page. GET .../runs is the sync log: one line per sync, newest first.

A page that disappears from the site is retired after two syncs in a row miss it, never after one. A sync that reads nothing (the site is down, behind a login, or blocks crawlers in robots.txt) fails with that reason and keeps what was learned before. Failed syncs retry after 5 minutes, doubling up to 6 hours. A page that says “valid until” a date (or ”… सम्म मान्य”, BS dates too) stops answering after it.

POST /v1/knowledge/search with {"query": "भेन्डिङ मेसिन कति पर्छ", "audience": "public"} returns what the assistant would find: facts from the knowledge graph, then passages from documents and websites. Any language; no AI is used. customers and staff audiences need a secret key.

GET /v1/knowledge/missing lists things that lack a property callers usually ask about: a product with no price, a branch with no hours or phone, the business with no contact or location. Each item has name, kind and missing. Fill these in and the assistant can answer.

Values are checked by type when they arrive. A price with no amount (“call us”), a phone with fewer than 7 digits or hours with no times are held for the owner instead of told to callers, and the write result counts them under held.

POST /v1/knowledge/ask with {"question": "तपाईंको पसल कति बजे खुल्छ?"} returns the assistant’s own answer from the public knowledge, with the business’s rules and its “don’t know” policy, and answered: false when it had no answer. Add history as [["earlier question", "earlier answer"], ...] (up to 10) for follow-ups. It never takes actions, and an answer with a price or number that is not in the knowledge is replaced by an honest “I don’t have that detail”. Each call is one AI answer and is billed like a chat message.

Subscribe a webhook endpoint to knowledge.* for:

EventWhen
knowledge.connection.syncedA sync ended; data.stats has what changed.
knowledge.connection.failedA sync failed; data.error says why, data.next_sync_at when it retries.
knowledge.connection.brokenFive syncs in a row failed. It keeps retrying; the owner is told.
knowledge.connection.removedA removal finished.
knowledge.connection.staleConnections are more than a day past their next sync (once a day, with their names).
knowledge.fact.conflictA pushed record disagrees with a stronger fact; the stronger one answers until the owner chooses.