4.9 KiB
4.9 KiB
Implementation Plan - Intaleq Customer Service & Driver Registration Flow
This plan details the implementation of the Intaleq customer service prompt template, the multi-stage WhatsApp driver registration flow using Gemini OCR, and the authenticated REST API endpoints for Nabeh's backend.
User Review Required
Important
- API Key Configuration: We will authenticate the REST endpoints using a shared
ENTALEQ_API_KEYdefined in the.envfile. Please ensure this environment variable is populated on your environment before calling these endpoints.- Direct Upload Path: Decoded WhatsApp images will be saved under the public directory
backend/public/uploads/documents/to ensure they are accessible via public URL paths.- Prompt Dialect: The custom service prompt is written in a professional, warm Syrian dialect (اللهجة السورية) adhering to all business rules.
Proposed Changes
Database Schema Component
[NEW] DriverOcrData.php
- Class extending
BaseModelthat manages thedriver_ocr_datatable. - Dynamically creates the table via
ensureTableExists(). - Implements
saveSecureto encrypt sensitive fields (phone,name,password, and all JSON OCR strings) using AES-256-GCM (Security::encrypt()) and generate search hashes (Security::blindIndex()). - Implements
findByPhoneto retrieve and decrypt records.
Gemini Service Component
[MODIFY] GeminiService.php
- Add the
generateOcrFromImagestatic method to support custom structured document analysis. It forwards custom prompts (e.g. green card OCR instructions) and base64 inline images to thegemini-2.0-flash-litemodel.
Dashboard Component
[MODIFY] index.html
- Add the new prompt template button:
<button type="button" class="btn btn-secondary" @click="loadPromptTemplate('intaleq')">قالب خدمة عملاء انطلق (سوري)</button>. - Add
intaleqtemplate case insideloadPromptTemplate(type)to load the full customer service system instruction prompt.
Conversation Flow Component
[NEW] DriverRegistrationFlow.php
- Implement a step-by-step driver registration state machine.
- Steps:
start: Welcome message, request full name.ask_name: Save name, request password.ask_password: Validate password, request ID Front image.id_front: Runid_front_syGemini OCR prompt. Request ID Back.id_back: Runid_back_syGemini OCR prompt. Request Driving License Front.driving_license_front: Rundriving_license_sy_frontGemini OCR prompt. Request Driving License Back.driving_license_back: Rundriving_license_sy_backGemini OCR prompt. Request Vehicle License Front.vehicle_license_front: Runvehicle_license_sy_frontGemini OCR prompt. Request Vehicle License Back.vehicle_license_back: Runvehicle_license_sy_backGemini OCR prompt. Request Criminal Record (لا حكم عليه).criminal_record: Save document, update status toocr_completed, save todriver_ocr_datatable, and conclude.
[MODIFY] ConversationFlowEngine.php
- Add trigger mappings:
'تسجيل' => 'driver_registration_flow','سجل' => 'driver_registration_flow', and'register' => 'driver_registration_flow'. - Register the flow class:
'driver_registration_flow' => DriverRegistrationFlow::class.
REST API Component
[MODIFY] index.php
- Define 2 REST API endpoints:
GET /api/external/driver-ocr: Accepts a query parameterphone. Authenticates againstENTALEQ_API_KEY. Retrieves and decrypts driver documents, OCR logs, and password details.POST /api/external/register-driver: Accepts aphonebody parameter. Authenticates againstENTALEQ_API_KEY. Marks the local record status asregistered(confirming transfer to primary DB).
Verification Plan
Manual Verification
- Open the dashboard, click قالب خدمة عملاء انطلق (سوري), and verify the prompt loads.
- Send a WhatsApp message to the bot saying
"تسجيل"and follow the registration wizard. Send test images for each stage, verifying database storage and Gemini OCR parsing logs. - Query the
GET /api/external/driver-ocrendpoint usingcurlwith the headerX-API-Key: your_keyand confirm decrypted data is returned. - Execute
POST /api/external/register-driverwith the API key header and confirm the record status updates toregistered.