Konusmalar API
Konusmalari programatik olarak yonetin.
Endpoints
| Method | Endpoint | Aciklama |
|---|---|---|
| GET | /conversations | Konusma listesi |
| GET | /conversations/:id | Konusma detayi |
| POST | /conversations/:id/messages | Mesaj gonder |
| PATCH | /conversations/:id | Durum guncelle |
Konusma Listesi
http
GET /api/v1/conversationsQuery Parameters
| Parametre | Tip | Aciklama |
|---|---|---|
| page | number | Sayfa numarasi |
| limit | number | Sayfa basi kayit |
| status | string | open, pending, closed |
| channel | string | whatsapp, instagram, telegram, widget |
| assignedTo | string | Atanan kullanici ID |
| contactId | string | Kisi ID'sine gore |
Ornek Yanit
json
{
"success": true,
"data": [
{
"id": "conv_abc123",
"contact": {
"id": "contact_xyz",
"name": "Ahmet Yilmaz",
"avatar": null
},
"channel": "whatsapp",
"status": "open",
"assignedTo": {
"id": "user_123",
"name": "Mehmet Demir"
},
"lastMessage": {
"text": "Merhaba, yardim alabilir miyim?",
"direction": "incoming",
"createdAt": "2024-01-21T10:30:00Z"
},
"unreadCount": 2,
"createdAt": "2024-01-21T10:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 45
}
}Konusma Detayi
http
GET /api/v1/conversations/:idOrnek Yanit
json
{
"success": true,
"data": {
"id": "conv_abc123",
"contact": {
"id": "contact_xyz",
"firstName": "Ahmet",
"lastName": "Yilmaz",
"phone": "+905551234567"
},
"channel": "whatsapp",
"channelId": "+905559876543",
"status": "open",
"assignedTo": {
"id": "user_123",
"name": "Mehmet Demir"
},
"tags": ["Destek", "Acil"],
"messages": [
{
"id": "msg_001",
"text": "Merhaba",
"direction": "incoming",
"status": "delivered",
"createdAt": "2024-01-21T10:00:00Z"
},
{
"id": "msg_002",
"text": "Merhaba, size nasil yardimci olabilirim?",
"direction": "outgoing",
"sender": {
"type": "ai",
"name": "DOLU Asistan"
},
"status": "read",
"createdAt": "2024-01-21T10:00:05Z"
}
],
"metadata": {
"source": "organic",
"firstResponseTime": 5,
"totalMessages": 12
},
"createdAt": "2024-01-21T10:00:00Z",
"updatedAt": "2024-01-21T10:30:00Z"
}
}Mesaj Gonderme
http
POST /api/v1/conversations/:id/messagesRequest Body
Metin Mesaji
json
{
"type": "text",
"text": "Merhaba, siparisiniaz hazirlandi."
}Medya Mesaji
json
{
"type": "image",
"mediaUrl": "https://example.com/image.jpg",
"caption": "Urun gorseli"
}Dosya Mesaji
json
{
"type": "document",
"mediaUrl": "https://example.com/doc.pdf",
"filename": "fiyat-listesi.pdf"
}Ornek Yanit
json
{
"success": true,
"data": {
"id": "msg_xyz789",
"text": "Merhaba, siparisiniaz hazirlandi.",
"direction": "outgoing",
"status": "sent",
"createdAt": "2024-01-21T11:00:00Z"
}
}Durum Guncelleme
http
PATCH /api/v1/conversations/:idRequest Body
json
{
"status": "closed",
"assignedTo": "user_456"
}Mumkun Durumlar
open- Acikpending- Beklemedeclosed- Kapali
Atama
http
POST /api/v1/conversations/:id/assignjson
{
"userId": "user_456"
}Etiketleme
Etiket Ekleme
http
POST /api/v1/conversations/:id/tagsjson
{
"tags": ["Acil", "VIP"]
}Etiket Silme
http
DELETE /api/v1/conversations/:id/tags/:tagNameMesaj Durumu
Mesaj durumu degerleri:
| Durum | Aciklama |
|---|---|
| pending | Gonderiliyor |
| sent | Gonderildi |
| delivered | Teslim edildi |
| read | Okundu |
| failed | Basarisiz |
Webhooks
Konusma olaylari icin webhook'lari kullanin:
conversation.created- Yeni konusmaconversation.updated- Durum degistimessage.received- Yeni mesaj geldimessage.sent- Mesaj gonderildi
