Skip to main content

Overview

The AI processing endpoint allows you to send text messages, images, audio, and PDFs for intelligent analysis. The system can respond synchronously or asynchronously (via postback).

Main Endpoint

POST /ai/process

Payload Parameters

tenant_id
string
required
Tenant ID (obtained from dashboard)
lead_id
string
required
ID of the lead sending the message
role
string
required
Sender role: user, assistant, human, system
content
string
required
Message content
message_type
string
required
Message type: text, image, audio, pdf
url
string
Media URL (required for types other than text)
debounce
boolean
default:"false"
When true, accumulates messages and sends response via postback
postback_url
string
URL to receive the response (required when debounce: true)

Request Example

curl -X POST "https://api.leavo.ai/ai/process" \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "tenant_id": "tenant-uuid",
    "lead_id": "lead-uuid",
    "role": "user",
    "content": "Hello, I would like to know more about the product",
    "message_type": "text",
    "debounce": true,
    "postback_url": "https://your-webhook.com/callback"
  }'

Message Types

Simple text message.
{
  "message_type": "text",
  "content": "Your message here"
}
Send an image for visual analysis.
{
  "message_type": "image",
  "content": "Optional description",
  "url": "https://example.com/image.jpg"
}
Send audio for transcription and analysis.
{
  "message_type": "audio",
  "url": "https://example.com/audio.mp3"
}
Send a PDF for content extraction.
{
  "message_type": "pdf",
  "url": "https://example.com/document.pdf"
}

Debounce Mode

Debounce mode is useful when you want to accumulate multiple messages before processing.

How It Works

  1. When debounce: true, the system accumulates messages for a configured time
  2. After the debounce time, all messages are processed together
  3. The response is sent to the postback_url

Request Flow

Synchronous Response (without debounce)

When debounce: false, the response is returned immediately:
{
  "success": true,
  "response": "Hello! Sure, I can help with information about our product..."
}

Postback Response

When debounce: true, the postback receives:
{
  "lead_id": "lead-uuid",
  "response": "Hello! Sure, I can help with information about our product...",
  "timestamp": "2024-01-15T10:30:00Z"
}