Skip to main content
This guide covers the messaging APIs for mobile applications, including conversation history, message retrieval, and sending messages with real-time streaming.

Prerequisites

Before using these APIs, configure authentication as described in Mobile Authentication.

Conversations

Retrieves the list of conversations for the authenticated user. Endpoint: GET /api/sdk/v1/conversations Response:
Usage Notes:
  • Returns up to 100 most recent conversations
  • Conversations are sorted by last message date (newest first)
  • Each conversation contains a unique ID used to retrieve messages

Get Conversation with Messages

Retrieves a specific conversation with all its messages. Endpoint: GET /api/sdk/v1/conversations/{conversation_id} Parameters:
  • conversation_id (path): UUID of the conversation
Response:
Message Fields:

Send New Message

Sends a new message to start or continue a conversation. Endpoint: POST /api/sdk/v1/messages Request Body:
Omit the thread field to start a new conversation. Include it to continue an existing thread.

SSE Response Format

The response is sent as Server-Sent Events (SSE) stream for real-time updates.

Event Format

Each SSE message follows this format:
Heartbeat messages (which can be ignored):

SSE Message Structure

Status Values

Example Stream

Form Presentation

If a form should be presented to the user (e.g., ticket creation):

JavaScript Implementation


Kotlin Implementation


Fallback Polling

If SSE streaming fails or is not supported, use polling as a fallback.

When to Use Polling

  • SSE connection fails or times out
  • Behind proxy that doesn’t support streaming
  • Mobile SDK with limited SSE support
  • Testing/debugging scenarios

Polling Endpoint

Endpoint: GET /api/sdk/v1/messages/{message_id}/status Response:

Polling Implementation

Polling Best Practices:
  • Poll every 2 seconds to balance responsiveness and server load
  • Set a maximum polling duration (e.g., 2-3 minutes)
  • Update UI with partial content while polling
  • Retry on network errors, stop on 4xx errors

Best Practices

SSE Handling

  • Always implement fallback polling for network interruptions
  • Buffer partial chunks before parsing JSON
  • Handle heartbeat messages gracefully (ignore them)
  • Track message_id for fallback polling

User Experience

  • Show typing indicators during message processing
  • Display content progressively as it streams
  • Update thread title when received
  • Show knowledge sources for transparency

Error Handling

  • Implement retry logic for network failures
  • Gracefully handle stream disconnections
  • Provide clear error messages to users
  • Log errors for debugging