New User Message

Send a new user message to the AI Chat API and receive an AI-generated response with conversation management.

Endpoint

POST/newUserMessage
Process a new user message and generate an AI response. Handles both new conversations and existing chat continuations.
https://chat-api.atriai.chat/newUserMessage

Authentication

Type:
Bearer Token
Header:
Authorization
Your project-specific API key for the Chat service

Request Parameters

The request body should contain a JSON object with the following parameters:

Request Body Parameters

user_messagestringREQUIRED

The user's message content to send to the AI chat system

chat_idstring

Unique identifier for an existing conversation. If not provided, a new conversation will be created

Default: null
consumer_idstring

Optional identifier for the consumer making the request. Required when chat_id is not provided

Default: null

Validation Rules

The following validation rules apply to the request:

Either chat_id or consumer_id must be provided

You cannot send a message without specifying either an existing conversation (chat_id) or a consumer identifier (consumer_id)

user_message cannot be empty

The user message content is required and cannot be an empty string

chat_id must be valid if provided

If a chat_id is provided, it must correspond to an existing conversation

Response Schema

The API returns a JSON object with the following structure:

assistant_responsestring

The AI-generated response to the user's message

chat_idstring

Unique identifier for the conversation (newly created or existing)

classificationstring

Classification of the user message type (e.g., 'question', 'greeting', 'request')

citationsarray[object]

Array of citation objects containing sources and references used in the response

Usage Examples

Common usage patterns for the New User Message endpoint:

Starting a New Conversation

Create a new conversation with a consumer_id

{
  "user_message": "Hello, I need help with my account",
  "consumer_id": "user_12345",
  "test": false
}

Continuing an Existing Conversation

Send a follow-up message to an existing chat

{
  "user_message": "Can you provide more details about that?",
  "chat_id": "chat_20240711_143052_abc123",
  "test": false
}

Response Example

Example response for a successful chat message:

{
  "assistant_response": "Hello! I'm an AI assistant. How can I help you today?",
  "chat_id": "chat_20240711_143052_abc123",
  "classification": "greeting",
  "citations": [
    {
      "source": "knowledge_base",
      "reference": "AI Assistant Capabilities v2.1",
      "confidence": 0.95
    }
  ]
}

Try it out

Select a language to see how to make a request to the AI Chat API

C
cURL Request
curl -L 'https://chat-api.atriai.chat/newUserMessage' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "user_message": "Hello, how are you?",
    "chat_id": "your_chat_id_here",
    "consumer_id": "optional_consumer_id",
    "test": false
  }'
!

API Key Required

Replace YOUR_API_KEY with your actual api key to authenticate requests.