6.9 CommunicationDiagnosticsController
Route: api/v{version:apiVersion}/Communication (same base prefix as CommunicationController,
differentiated by action-level route segments) · Class attributes: [Authorize] · 7 endpoints — deep
health/smoke-test tooling for support engineers and platform administrators.
Production safety note: these endpoints reveal detailed configuration and resolution-decision information. See §11 Security before exposing them beyond an authenticated admin/support role.
GET Health
Purpose: aggregate health across every communication channel and engine — a single-call system status
check. Permission: Communications.Health · Request: none
Response data (abbreviated):
{ "version": "5.2", "checkedAt": "2026-07-05T12:00:00Z", "overallStatus": 1,
"whatsAppStatus": { "name": "WhatsApp", "status": 1, "isConfigured": true, "isEnabled": true,
"details": { "graphApiVersion": "v25.0", "phoneNumberId": "1088...326" } },
"warnings": [], "recommendations": [] }
Backend: CommunicationDiagnosticsService.GetHealthAsync — checks configuration presence/shape only.
Calls Meta API: No.
POST SmokeTest
Purpose: 7-step end-to-end email send-and-verify smoke test. Permission: Communications.SmokeTest
Request (SmokeTestRequest): { "toEmail": "qa@tenant.com", "languageCode": "ar", "testType": 1 }
Response: Result<SmokeTestReport> with a steps[] array (name, passed, durationMs, details/error).
Backend: CommunicationDiagnosticsService.RunEmailSmokeTestAsync. Calls Meta API: No.
POST SmokeTest/WhatsApp
Purpose: 7-step end-to-end WhatsApp smoke test: config check → template resolution → connectivity test →
real dispatch → history verification → delivery receipt verification → analytics verification.
Permission: Communications.SmokeTest · Request (SmokeTestRequest):
{ "toPhone": "966501112222", "languageCode": "ar", "testType": 6 }
Response (Result<SmokeTestReport>):
{ "testId": "t1...", "testType": 6, "passed": true, "executionTimeMs": 1840,
"steps": [
{ "name": "ConfigurationCheck", "passed": true, "durationMs": 4 },
{ "name": "TemplateResolution", "passed": true, "durationMs": 2 },
{ "name": "ConnectivityTest", "passed": true, "durationMs": 310 },
{ "name": "Dispatch", "passed": true, "durationMs": 1420 },
{ "name": "HistoryVerification", "passed": true, "durationMs": 8 },
{ "name": "DeliveryReceiptVerification", "passed": true, "durationMs": 90 },
{ "name": "AnalyticsVerification", "passed": true, "durationMs": 6 } ],
"historyVerified": true, "deliveryAttemptVerified": true, "analyticsVerified": true }
Error cases: a real template send occurs in step "Dispatch" — running this against a production tenant
sends a real WhatsApp message to toPhone; use only with a controlled test number.
Backend: CommunicationDiagnosticsService.RunWhatsAppSmokeTestAsync — step 3 calls
ITenantWhatsAppSender.TestConnectionAsync, step 4 calls ICommunicationService.SendWhatsAppAsync.
Calls Meta API: Yes (steps 3 and 4).
POST Diagnostics/Providers
Purpose: explain provider/template resolution decisions for a channel without sending anything.
Permission: Communications.Diagnostics · Request (query):
?channel=WhatsApp&templateBaseName=send_document&languageCode=ar
Response data: { "channel": "WhatsApp", "providerSelected": "Meta WhatsApp Cloud API", "languageResolved": "ar", "templateResolved": "send_document_ar", "isConfigured": true, "isEnabled": true, "fallbackDecisions": ["Requested language 'fr' not supported, fell back to tenant default 'ar'"] }
Backend: CommunicationDiagnosticsService.DiagnoseProviderResolutionAsync. Calls Meta API: No.
GET Diagnostics/Email · GET Diagnostics/WhatsApp
Purpose: validate a channel's configuration and surface soft warnings (not hard errors).
Permission: Communications.Diagnostics · Response data (WhatsApp):
{ "isValid": true, "errors": [], "warnings": ["DefaultTemplatePrefix not customized", "WebhookEnabled is false — inbound replies will not be received for this tenant's own number"] }
Backend: CommunicationDiagnosticsService.ValidateEmailConfigAsync / ValidateWhatsAppConfigAsync.
Calls Meta API: No.
POST Diagnostics/PrintPreview
Purpose: validate a would-be send (recipient, provider config, template resolution) without sending —
used by document print/preview screens to show a "this will fail to send" warning before the user tries.
Permission: Communications.Diagnostics · Request (PrintPreviewValidationRequest):
{ "recipientPhone": "966501112222", "languageCode": "ar", "channel": 2,
"documentType": "Invoice", "documentId": "inv-...", "documentNumber": "INV-2026-00451" }
Response (Result<PrintPreviewValidationReport>):
{ "isValid": true, "channel": 2, "providerSelected": "Meta WhatsApp Cloud API", "senderIdentity": "966501234567",
"templateResolved": "send_document_invoice_ar", "languageResolved": "ar", "recipientValid": true,
"recipientContact": "966501112222", "providerConfigured": true, "providerEnabled": true,
"validationErrors": [], "warnings": [] }
Backend: CommunicationDiagnosticsService.ValidatePrintPreviewAsync. Calls Meta API: No.
Angular/Flutter: call before enabling a "Send" button on any document print/preview screen so the user
sees configuration problems (e.g. missing phone number) before attempting a send.
