Omnichannel Communication & Dispatch

Multi-channel SMS, Email, WhatsApp, and Push dispatching with intelligent failover, bilingual Liquid templates, and delivery receipts.

The Communication module acts as SCRIPE's centralized messaging gateway, orchestrating transactional and operational notifications across SMS, Email, WhatsApp, and Realtime Push. Featuring intelligent provider failover, bilingual template interpolation (English and Arabic), and delivery audit logs, it guarantees critical operational messages reach athletes, parents, and staff.

Communication Architecture

Designed to handle high-volume notification spikes during major tournament registrations and schedule changes.

  • Multi-Provider Gateways

    Pluggable provider adapters for Twilio, SendGrid, Unifonic, AWS SES, and custom SMTP/SMPP endpoints.

  • Transactional Email

    HTML/text email delivery with delivery tracking, bounce management, and DKIM/SPF compliance.

  • High-Throughput SMS

    Global and local SMS dispatching with country-code normalization and GSM-7 character optimization.

  • Bilingual Scriban Templates

    Dynamic variable interpolation with built-in preview tools, supporting LTR English and RTL Arabic layouts.

  • Automated Provider Failover

    Seamless fallback to secondary channels upon HTTP 5xx errors or network timeout thresholds.

  • Immutable Delivery Receipts

    Audited delivery attempt logs with provider message IDs, timestamps, and error codes for dispute resolution.

Domain Aggregate Root: ChannelConfiguration

The ChannelConfiguration aggregate manages provider credentials, rate limiting rules, priority routing, and delivery telemetry.

src/Modules/Communication/Communication.Domain/Entities/ChannelConfiguration.csC#
public sealed class ChannelConfiguration : TenantAggregateRoot
{
    public CommunicationChannelType ChannelType { get; private set; } // Email, Sms, WhatsApp, Push
    public string ProviderName { get; private set; } = string.Empty; // SendGrid, Twilio, Unifonic, Smtp
    public string ConfigurationJson { get; private set; } = "{}";
    public bool IsPrimary { get; private set; }
    public bool IsActive { get; private set; }
    public int RateLimitPerMinute { get; private set; } = 100;
    public List<DeliveryAttempt> RecentDeliveryAttempts { get; private set; } = new();

    public void RecordDeliveryAttempt(string messageId, bool success, string? errorMessage)
    {
        RecentDeliveryAttempts.Add(new DeliveryAttempt(Id, messageId, success, errorMessage, DateTimeOffset.UtcNow));
        RaiseDomainEvent(new DeliveryAttemptRecordedDomainEvent(Id, TenantId, messageId, success));
    }
}

Failover Dispatching & Delivery Pipeline

The step-by-step lifecycle of an outbound transactional notification from event trigger to confirmed receipt:

Event Trigger (e.g. BookingConfirmed, InvoiceIssued)
Resolve MessageTemplate by key + recipient language
Interpolate Liquid/Scriban variables with event payload
Select Primary Channel (e.g. Twilio SMS)
Dispatch attempt; verify HTTP status & webhook receipt
If failed: Route to secondary fallback channel (e.g. Unifonic)
Record immutable SentSmsLog & DeliveryAttempt audit record

Primary API Endpoints

Key endpoints exposed by CommunicationControllers for channel setup, template authoring, and message dispatching.

MethodEndpointDescriptionAuth
GET/api/v1/communication/channelsList configured communication channels and operational status🔒 Required
POST/api/v1/communication/channelsConfigure a new SMS, Email, or WhatsApp provider adapter🔒 Required
GET/api/v1/communication/templatesRetrieve bilingual message templates with variable schemas🔒 Required
POST/api/v1/communication/templates/render-previewRender a live template preview with mock parameter variables🔒 Required
POST/api/v1/communication/messages/send-smsDispatch an urgent SMS notification to one or more phone numbers🔒 Required
GET/api/v1/communication/logs/smsQuery immutable delivery logs and provider delivery statuses🔒 Required