Skip to main content
Messages are individual communications within a conversation. Each message can contain text or media content and maintains metadata about its creation and status.

Send Message

Send a new message in a conversation.
  • Endpoint: POST /messages
  • Authentication: API Key Required

Headers

Message Types

The content_type field determines the message format and required fields:
  1. TEXT ("content_type": "text")
    • Basic text messages
    • Requires content field
    • No file handling needed
  2. MEDIA (audio/*, image/*, application/pdf, etc.)
    • Used for file attachments
    • Requires filename field
    • Must obtain pre-signed URL before upload
    • Supports various formats (audio, image, PDF, XLSX, CSV)
    • More detail below Media Handling

Request Body

Example: Text Message

Example: Media Message

Response

Supported Content Types

Status Codes

  • 200: Message sent successfully
  • 400: Validation error
  • 401: Invalid or missing API key
  • 422: Missing organization ID
  • 500: Server error

Example Request

Notes

  1. File Uploads:
    • Obtain pre-signed URL before uploading media
    • Use appropriate content type headers
    • Respect file size limits
  2. Message Processing:
    • Messages are processed asynchronously
    • Check message status for delivery confirmation
    • All timestamps are in UTC
  3. Metadata Usage:
    • Use metadata for custom tracking
    • Metadata must be valid JSON
    • Maximum metadata size: 4KB
  4. Rate Limits:
    • 100 messages per minute per organization
    • Larger limits available for enterprise plans

Media Handling

For sending media messages (images, audio, PDFs, etc.), you’ll need to follow a three-step process:

Step 1: Get Pre-signed URL

Endpoint: POST /media/presigned-url Headers:
Request Body:
Response:
Curl Example:

Step 2: Upload File

Use the pre-signed URL to upload your file:
Note: Replace ${PRESIGNED_URL} with the URL received from Step 1, and adjust the file path to your local file location.

Step 3: Send Message

After successful upload, send the message:
Curl Example:

Supported File Types

Complete Example

Media Upload Notes

  1. File Naming:
    • Uploaded files are automatically prefixed with timestamp
    • Format: YYYYMMDD_HHMMSS_original_filename
  2. Storage Organization:
    • Files are stored in type-specific folders
    • Each organization has its own directory
    • Maintains clean separation of different file types
  3. Limitations:
    • Text files are not supported for pre-signed URLs
    • Pre-signed URLs expire after 15 minutes
    • File type must match the declared content type
  4. Error Cases:
    • 422: Missing organization ID
    • 400: Invalid file type or unsupported operation
    • 500: Server error during URL generation

Message Metadata

The metadata field in messages serves several critical functions:
  1. File Storage Information
    • Tracks file storage details for system generated files
    • Used when system generates a file response
    • System automatically processes the file:
      • Extracts bucket and path information
      • Transfers file to conversation media bucket
      • Updates message with standardized S3 URI
    • Supports both HTTPS and S3 protocol URLs
    • File access requires proper authentication
    • Example message metadata:
  2. Workflow Instance Status
    The metadata tracks workflow execution state through the workflow_instance_status field: Available Status Values Example Status Updates === “Initial workflow start”
    === “Workflow paused for user input”
    === “Workflow completion”
    Status Transitions
    • RUNNING → Any status
    • PAUSEDRUNNING, CANCELLED, TERMINATED
    • COMPLETED (Terminal state)
    • FAILED (Terminal state)
    • CANCELLED (Terminal state)
    • TERMINATED (Terminal state)
    Important Notes
    • Status updates are real-time
    • Terminal states cannot transition to other states
    • Each status update includes timestamp information
    • Status changes may trigger notifications or webhook events
    • Historical status changes are preserved in workflow logs
  3. Ticket Integration
    The metadata contains ticket information that automatically manages support ticket lifecycles: Status Management
    • Ticket status is automatically updated based on task instance status:
    • Updates are handled atomically to prevent race conditions
    • Status changes are tracked in ticket history
    Ticket Fields Important ticket information tracked:
    Example Metadata Usage
    Notification System When tickets are created or updated:
    • Assignees receive email notifications
    • Notifications include:
      • Ticket ID
      • Task name and description
      • Workflow name
      • Exception details (if any)
      • Assignment details
    Important Notes
    • Ticket updates are processed atomically using database transactions
    • Missing ticket IDs are safely ignored
    • Status updates are immediate and automatic
    • All ticket activities are logged for audit purposes

Example Message with Complex Metadata