Skip to main content
Generates an AI response for a customer message using your assistant. Conversations are automatically created or resumed based on the customer_identifier, making this ideal for integrating AI replies into external platforms, CRMs, or custom messaging interfaces.
This endpoint is rate-limited to 5 requests per minute per API token.

Endpoint

POST /user/ai/generate-reply

Request

assistant_id
integer
required
ID of the assistant to use. Must belong to your account.
customer_identifier
string
required
A unique identifier for the customer. Used to maintain conversation context across multiple messages. Examples: phone number, email, CRM contact ID, Facebook user ID. Maximum 255 characters.
message
string
required
The customer’s message to respond to.
variables
object
Optional context variables to pass to the assistant. Merged with any existing conversation variables.

Response

success
boolean
Whether the request was successful.
conversation_id
string
UUID of the conversation. Use this to reference the conversation later.
customer_identifier
string
The customer identifier provided in the request.
reply
string
The AI-generated response.
function_calls
array
Functions the assistant executed while processing the message.
ai_disabled
boolean
Whether AI responses are disabled for this conversation (e.g., due to manual takeover).

Example

curl -X POST "https://portal.intellixent.ai/api/user/ai/generate-reply" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "assistant_id": 123,
    "customer_identifier": "+14155551234",
    "message": "Hi, I would like to schedule an appointment",
    "variables": {
      "customer_name": "John Smith",
      "source": "whatsapp"
    }
  }'
200 Success
{
  "success": true,
  "conversation_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "customer_identifier": "+14155551234",
  "reply": "Hi John! I'd be happy to help you schedule an appointment. What day and time work best for you?",
  "function_calls": [],
  "ai_disabled": false
}
404 Assistant not found
{
  "success": false,
  "error": "Assistant not found or does not belong to you",
  "error_code": "ASSISTANT_NOT_FOUND"
}
402 Insufficient balance
{
  "success": false,
  "error": "Insufficient balance. Please top up your account.",
  "error_code": "INSUFFICIENT_BALANCE"
}
429 Rate limited
{
  "message": "Too Many Attempts.",
  "retry_after": 60
}

Conversation persistence

Conversations are automatically persisted by assistant_id + customer_identifier:
  • Same identifier: Messages are added to the existing conversation, maintaining full context.
  • New identifier: A new conversation is created.
  • Variables merge: Variables provided in the request are merged with existing conversation variables.
Use consistent identifier formats (e.g., always E.164 format for phone numbers) to ensure conversation continuity across requests.