Skip to navigation

Send Chat Message (Async)

Send a message to the AI chat assistant. The response is delivered asynchronously via WebSocket — subscribe to the UserChannel to receive the AI_CHAT_RESPONSE event.

Authentication: Required — Bearer token.

Prerequisites: LoyalStream connector must be enabled on the app.

Request body:

  • client_id (required) — Client-generated unique ID for tracking the conversation
  • message (required) — The user’s message text
  • conversation_id (optional) — Existing conversation ID to continue a conversation

Response:

  • status — “queued” (message is being processed)
  • client_id — Echo of the client_id for correlation

Side effects:

  • Broadcasts an AI_CHAT_RESPONSE event with “started” status immediately
  • Enqueues an AiChatJob via Sidekiq for async processing
  • The job broadcasts the AI response via WebSocket when complete

Errors:

  • 403 — LoyalStream connector not available
  • 500 — Failed to enqueue the chat job

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Request

This endpoint expects an object.
client_idstringOptional
messagestringOptional
conversation_idstringOptional

Response

OK