Skip to main content

What is a Postback?

Postback is how the API notifies your system when AI processing is complete in debounce mode.

Configuration

When calling /ai/process with debounce: true, you must provide a postback_url:
{
  "tenant_id": "uuid",
  "lead_id": "uuid",
  "content": "Hello",
  "message_type": "text",
  "debounce": true,
  "postback_url": "https://your-app.com/ai-callback"
}

Payload Received

Your endpoint will receive a POST with:
{
  "lead_id": "lead-uuid",
  "tenant_id": "tenant-uuid",
  "response": "AI response here...",
  "timestamp": "2024-01-15T10:30:00Z",
  "messages_processed": 3
}

Endpoint Example

app.post('/ai-callback', express.json(), (req, res) => {
  const { lead_id, response, timestamp } = req.body;

  // Respond quickly
  res.status(200).send('OK');

  // Process in background
  processAIResponse(lead_id, response);
});

async function processAIResponse(leadId, response) {
  // Send response to user via WhatsApp, etc.
  await sendWhatsAppMessage(leadId, response);
}

Requirements

HTTPS

URL must be HTTPS

Status 2xx

Return status 200-299

Timeout 30s

Respond within 30 seconds

Idempotent

Handle potential duplicates