Skip to Content
The Ngamia platform API is in preview. Endpoints may change before general availability.
GuidesAdd knowledge

Add knowledge

Documents

curl -s https://api.ngamia.com/v1/knowledge/documents -H "Authorization: Bearer $NGAMIA_TOKEN" \ -H 'content-type: application/json' -d '{ "source_id": "faq", "external_id": "delivery", "kind": "faq", "title": "Usafirishaji / Delivery", "text": "Tunasafirisha ndani ya Dar es Salaam kwa TZS 5,000 siku hiyo hiyo kwa oda kabla ya saa 6 mchana. We deliver within Dar es Salaam for TZS 5,000, same day for orders before noon.", "lang": "mixed" }'

Re-send the same source_id and external_id to update it. Delete with DELETE /v1/knowledge/documents/{id} using the document ID returned when it was stored.

Many documents

Keep your knowledge in a file in your repository and load it with a script. The Invoice example does exactly this with knowledge.json and setup.py. Running the script again updates everything in place.

Files

curl -s https://api.ngamia.com/v1/knowledge/files -H "Authorization: Bearer $NGAMIA_TOKEN" \ -F file=@price-list.pdf -F source_id=documents curl -s https://api.ngamia.com/v1/knowledge/jobs -H "Authorization: Bearer $NGAMIA_TOKEN"

Files are scanned, parsed and indexed in the background. Wait for the job to finish before testing.

Check what agents will find

curl -s https://api.ngamia.com/v1/knowledge/search -H "Authorization: Bearer $NGAMIA_TOKEN" \ -H 'content-type: application/json' -d '{"query":"mnasafirisha Mbezi?","limit":3}' \ | jq '.hits[] | {source_title, score}'

Write down ten to twenty real customer questions with the document each should find, and check them after every knowledge change. The Invoice example’s eval.json shows the format.