Files
crm.clientright.ru/aiassist/crm_handler.php
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

55 lines
2.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// assistance/crm_handler.php
/**
* Отправляет финальный результат анализа в CRM.
*
* @param string $caseId Идентификатор кейса.
* @param array $analysis Массив с результатами анализа (например, статус, контент, вердикт).
* @return bool Успешно ли выполнена отправка.
*/
function sendAnalysisToCRM($caseId, $analysis) {
// Формируем финальный ответ
$final_output = [
"case_id" => $caseId,
"status" => $analysis['status'] ?? 'error',
"content" => $analysis['content'] ?? 'Анализ не выполнен',
"moderationVerdict" => $analysis['moderationVerdict'] ?? 'Не определен'
];
// Пример URL API CRM (замените на реальный адрес API вашего CRM)
$crm_api_url = "https://your-crm.example.com/api/analysis";
$json_output = json_encode($final_output, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
if ($json_output === false) {
logMessage("Ошибка кодирования JSON в crm_handler: " . json_last_error_msg());
return false;
}
$ch = curl_init($crm_api_url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $json_output,
CURLOPT_HTTPHEADER => ['Content-Type: application/json']
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);
if ($curlError) {
logMessage("Ошибка cURL в crm_handler: " . $curlError);
return false;
}
if ($httpCode < 200 || $httpCode >= 300) {
logMessage("Ошибка отправки в CRM: HTTP $httpCode - " . $response);
return false;
}
logMessage("Анализ успешно отправлен в CRM: " . $response);
return true;
}
?>