Skip to main content
This page covers the conversation and message endpoints a native chat screen needs. Paths are relative to https://your-workspace.api.useago.com/api/sdk/v1. Every request carries the headers described in Mobile Authentication. The SDK API reference lists every field and the endpoints not covered here.

List Conversations

Endpoint: GET /conversations Returns the user’s conversations, most recent first.

Unread Count

Endpoint: GET /conversations/unread Returns how many conversations have messages from your support team that the user hasn’t read yet. Use it for a badge on your chat entry point.
Fetch the count when the app comes to the foreground and then at most every 30 seconds, which is what the AGO widget does. Make sure only one request is in flight per device: cancel or skip a new request while the previous one is pending.

Get a Conversation

Endpoint: GET /conversations/{conversation_id} Returns the conversation with all its messages, oldest first.

Send a Message

Endpoint: POST /messages Sends a message and streams the answer as Server-Sent Events (text/event-stream).
Store the conversation ID returned in the stream (thread.id) and send it back as conversation_id. It can differ from the ID you sent: see Forked conversations.

Attach Files

Send multipart/form-data instead of JSON, with content, conversation_id and agent_id as form fields and one files part per file. You can attach up to 5 files of 10 MB each. Check file_attachments_enabled in GET /config before showing an attach button: the endpoint returns 403 when attachments are turned off.

Streaming Response

Each event is a line starting with data: followed by a JSON object, and events are separated by a blank line. Lines starting with : (: heartbeat) keep the connection open and carry no data. Read each event’s keys to identify its contents. File rejection events use type: file_error and an error message.

Example Stream

The stream can continue after DONE with the title and suggested replies. Read it until the server closes it.

Fallback Polling

Mobile networks drop long connections. If the stream ends before DONE or ERROR, poll the answer instead of sending the message again. Endpoint: GET /messages/{message_id}/status
content holds the whole answer so far: replace the displayed text with it. Poll every 2 seconds while status is TODO (queued) or IN_PROGRESS. An answer still in progress 3 minutes after it started is reported as ERROR. To let users cancel an answer, call POST /messages/{message_id}/stop. Closing the stream alone doesn’t stop the agent.

Kotlin (Android) Example

Uses OkHttp and its okhttp-sse module, which skips heartbeat lines for you.
AgoClient is the request builder from Mobile Authentication. For Swift, see Mobile SDK Examples.