API Reference
תיעוד מלא של כל ה-API endpoints
תוכן עניינים
Base URL
https://labs.levor.io/api/mcp-chatbot
כל ה-endpoints דורשים אימות (Login Required).
שיחות (Conversations)
GET
/conversations
קבלת רשימת השיחות של המשתמש המחובר
Query Parameters:
| פרמטר | סוג | תיאור |
|---|---|---|
page |
integer (optional) | מספר עמוד (ברירת מחדל: 1) |
per_page |
integer (optional) | פריטים לעמוד (ברירת מחדל: 20) |
status |
string (optional) | סינון לפי סטטוס: active, archived, all |
Response:
{
"success": true,
"conversations": [
{
"id": 1,
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"title": "שיחה על לקוח דוד כהן",
"status": "active",
"primary_context_type": "customer",
"customer_id": 123,
"message_count": 5,
"created_at": "2025-12-01T10:00:00",
"last_message_at": "2025-12-01T10:15:00",
"context_summary": {
"customer": {
"id": 123,
"name": "דוד כהן",
"phone": "050-1234567"
}
}
}
],
"total": 15,
"pages": 1,
"current_page": 1
}
POST
/conversations
יצירת שיחה חדשה
Request Body:
{
"prompt_id": 1, // optional - ID של פרומפט
"provider_id": 1, // optional - ספק AI
"model_id": 1, // optional - מודל AI
"context_type": "customer", // optional - סוג הקשר
"context_id": 123 // optional - ID של הישות
}
Response (201 Created):
{
"success": true,
"conversation": {
"id": 2,
"uuid": "...",
"title": "שיחה חדשה",
"status": "active",
...
}
}
GET
/conversations/{id}
קבלת שיחה בודדת עם כל ההודעות
Response:
{
"success": true,
"conversation": {
"id": 1,
"title": "שיחה על לקוח",
"messages": [
{
"id": 1,
"role": "user",
"content": "מה היתרה של 050-1234567?",
"created_at": "..."
},
{
"id": 2,
"role": "assistant",
"content": "**יתרת הלקוח:**...",
"detected_intent": "customer_balance",
"function_result": {...}
}
]
}
}
PUT
/conversations/{id}
עדכון שיחה (כותרת, סטטוס, הקשר)
Request Body:
{
"title": "כותרת חדשה",
"status": "archived",
"customer_id": 456
}
DELETE
/conversations/{id}
מחיקת שיחה (Soft Delete - מעביר לארכיון)
הודעות (Messages)
POST
/conversations/{id}/messages
שליחת הודעה ועיבודה - הנקודה המרכזית של הצ'אטבוט
Request Body:
{
"message": "מה היתרה של 050-1234567?"
}
Response:
{
"success": true,
"response": "**יתרת הלקוח דוד כהן:**\n- יתרה: ₪1,234.00\n- חשבוניות לא שולמו: 2\n- סה\"כ לתשלום: ₪1,234.00",
"intent": "customer_balance",
"entities": [
{"type": "phone", "value": "0501234567"}
],
"context": {
"customer": {
"id": 123,
"name": "דוד כהן"
}
},
"functions_used": ["get_customer_balance"],
"response_time_ms": 245,
"conversation": {...}
}
צ'אט מהיר (Quick Chat)
POST
/chat
שליחת הודעה מהירה - יוצר שיחה אוטומטית אם צריך
Request Body:
{
"message": "מה היתרה של 050-1234567?",
"conversation_id": null, // optional - אם לא קיים, ייווצר חדש
"context_type": "customer",
"context_id": 123
}
Response:
{
"success": true,
"conversation_id": 5, // ID של השיחה (חדשה או קיימת)
"response": "...",
"intent": "customer_balance",
"entities": [...],
"functions_used": ["get_customer_balance"]
}
פרומפטים (Prompts)
GET
/prompts
קבלת רשימת פרומפטים פעילים
GET
/prompts/{id}
קבלת פרומפט בודד עם כל הפרטים
POST
/prompts
יצירת פרומפט חדש
{
"name": "my_assistant",
"display_name": "העוזר שלי",
"base_prompt": "אתה עוזר מקצועי...",
"personality": "ידידותי ומקצועי",
"customer_instructions": "הנחיות לטיפול בלקוחות...",
"invoice_instructions": "הנחיות לטיפול בחשבוניות...",
"repair_instructions": "הנחיות לטיפול בתיקונים...",
"temperature": 0.3,
"max_tokens": 2048,
"is_default": false
}
PUT
/prompts/{id}
עדכון פרומפט קיים
פונקציות (Functions)
GET
/functions/available
קבלת רשימת הפונקציות הזמינות בפורמט OpenAI
{
"success": true,
"functions": [
{
"name": "get_customer_by_phone",
"description": "מציאת לקוח לפי מספר טלפון",
"parameters": {
"type": "object",
"properties": {
"phone": {"type": "string", "description": "מספר טלפון"}
},
"required": ["phone"]
}
},
{
"name": "get_customer_balance",
"description": "קבלת יתרה וחוב של לקוח",
...
},
...
]
}
בסיס ידע (Knowledge Base)
GET
/knowledge
קבלת פריטי בסיס הידע
| פרמטר | סוג | תיאור |
|---|---|---|
category |
string | סינון לפי קטגוריה: faq, policy, procedure, product |
search |
string | חיפוש בכותרת ותוכן |
POST
/knowledge
הוספת פריט לבסיס הידע
{
"category": "faq",
"subcategory": "customers",
"title": "איך לבדוק יתרת לקוח?",
"content": "ניתן לבדוק יתרת לקוח על ידי...",
"keywords": ["יתרה", "חוב", "לקוח"],
"related_modules": ["customer"],
"priority": 10
}
סטטיסטיקות (Stats)
GET
/stats
סטטיסטיקות שימוש של המשתמש
{
"success": true,
"stats": {
"total_conversations": 25,
"active_conversations": 5,
"total_messages": 150,
"conversations_today": 3,
"conversations_this_week": 12,
"top_intents": [
{"intent": "customer_balance", "count": 45},
{"intent": "repair_status", "count": 30},
{"intent": "invoice_status", "count": 25}
]
}
}
תגובות שגיאה
// 400 Bad Request
{
"success": false,
"error": "נדרשת הודעה"
}
// 404 Not Found
{
"success": false,
"error": "שיחה לא נמצאה"
}
// 500 Internal Server Error
{
"success": false,
"error": "שגיאת שרת פנימית"
}