Conversations API
Create and manage conversations with AI employees.
List Conversations
GET /conversations
curl -X GET "https://your-instance.elestio.app/api/v1/conversations" \
-H "Authorization: Bearer YOUR_API_KEY"Query parameters:
employee_id- Filter by employeestatus- Filter by status (active, closed)page- Page number for pagination
Create Conversation
POST /conversations
curl -X POST "https://your-instance.elestio.app/api/v1/conversations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"employee_id": "emp_abc123",
"channel": "api",
"metadata": {
"customer_id": "cust_xyz",
"source": "website"
}
}'Send Message
POST /conversations/:id/messages
curl -X POST "https://your-instance.elestio.app/api/v1/conversations/conv_123/messages" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Hello, I need help with my order",
"role": "user"
}'Response includes the AI employee's reply:
JSON Response
{
"success": true,
"data": {
"user_message": {
"id": "msg_001",
"content": "Hello, I need help with my order",
"role": "user",
"created_at": "2024-01-15T10:30:00Z"
},
"assistant_message": {
"id": "msg_002",
"content": "Hi! I'd be happy to help you with your order. Could you please provide your order number?",
"role": "assistant",
"created_at": "2024-01-15T10:30:01Z"
}
}
}Get Messages
GET /conversations/:id/messages
curl -X GET "https://your-instance.elestio.app/api/v1/conversations/conv_123/messages" \
-H "Authorization: Bearer YOUR_API_KEY"Close Conversation
POST /conversations/:id/close
curl -X POST "https://your-instance.elestio.app/api/v1/conversations/conv_123/close" \
-H "Authorization: Bearer YOUR_API_KEY"Conversation Object
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier |
employee_id | string | Assigned employee |
channel | string | chat, email, voice, api, widget |
status | string | active or closed |
metadata | object | Custom metadata |
message_count | integer | Total messages |
created_at | datetime | Creation timestamp |