Use a chatbot API: send messages, stream replies, handle errors
A chatbot API lets your own app, portal or backend talk to your support agent. See when it beats a widget, and the request, streaming and error handling you need.
Read articleWhat a chatbot API does, the request and response you can expect, how streaming and user identity work, and the builds that make sense when you use an API instead of a widget.
By the Askocto team · · 5 min read
A chatbot API is a way for your own software to send a customer message to an AI agent and receive the reply as data. Instead of using a ready-made chat window, you call an endpoint from your app, your backend or a script and decide how to show the answer. This article explains the pieces and when an API is the right choice.
In short: Use a widget when you want chat on a website with little code. Use an API when you need the agent inside your own app, in a custom interface or inside another workflow.
At its core, one call does one thing: it sends a message and gets a reply. Around that sit a few supporting capabilities that you will want as soon as you build something real:
Here is an example against an Askocto agent, using the v2 chat endpoint. The key is created under Workspace Settings > API keys and sent as a bearer token.
curl https://api.askocto.co/v2/agents/agt_123/chat \
-H "Authorization: Bearer $OCTO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{ "role": "user", "content": "Where is my order?" }
],
"userId": "usr_456",
"stream": false
}'
A typical response includes the conversation ID to reuse, the reply text and the sources used, plus a usage record:
{
"conversationId": "conv_789",
"message": {
"id": "msg_001",
"role": "assistant",
"content": "Your order shipped on Tuesday. Here is the tracking link.",
"sources": [{ "id": "src_12", "title": "Shipping times" }]
},
"usage": { "credits": 1 }
}
Send conversationId in your next call and the agent continues the same thread. The full parameter list is in the chat endpoint reference.
Waiting for a whole answer feels slow. With streaming switched on, the server sends the answer as a series of events. Your interface appends each piece as it arrives and stops when it receives a final marker. Plan for two cases in your code:
For batch jobs, such as drafting replies to a backlog, the non-streaming call is simpler.
An API call can carry the identity of the signed-in person. That lets the agent address them by name, find their orders and keep a history across sessions. Treat identity as a security matter:
| Situation | Better fit |
|---|---|
| A support bubble on a marketing site | Widget |
| Chat inside a mobile app with custom styling | API or SDK |
| An internal tool where staff ask the agent questions | API |
| A voice or kiosk interface | API |
| Pushing conversation data into a warehouse | API plus webhooks |
| A custom portal with account data on screen | API |
If you mostly want the first row, read how to add an AI chatbot to your website. It is faster.
For the broader view of how chat connects to other systems, how to use a chatbot API looks at common integration patterns, and chatbot analytics shows what to do with the data you pull out.
Plan for failure from the first version.
Log the request ID that comes back with errors. It makes a support request to the vendor much faster.
Askocto also offers webhooks for events such as conversation.handoff and ticket.created, signed so you can verify them. You can read the API integration guide for the full walkthrough, or create a free account and try the first call.
It is an interface that lets your software send messages to a chatbot and receive its replies as structured data, so you can use the bot in your own app or workflow.
Not usually. A widget covers a website bubble. You need the API for custom interfaces, internal tools or data pipelines.
Do not put a secret API key in browser code. Call the API from your server, or use a client method designed for the browser that does not expose your key.
Most chatbot APIs support streaming. It sends the text in pieces so your interface can show the reply as it is written.
Askocto answers the repeat questions across chat, email and voice and hands the hard ones to your team.
A chatbot API lets your own app, portal or backend talk to your support agent. See when it beats a widget, and the request, streaming and error handling you need.
Read articleA buyer's guide to pairing an AI agent with Zendesk: criteria to compare, questions for a demo, a two-week trial plan using your own tickets and a rollout checklist.
Read articleA buyer's guide for connecting an AI support agent to Zendesk through Sunshine: what to compare, what to ask in a demo, and how to test with your own tickets.
Read article