Unified notification engine for MemberJunction that handles in-app, email, and SMS delivery based on notification types and user preferences. This server-side package coordinates between the MJ entity system, template engine, and communication engine to deliver notifications through the appropriate channels.
graph TD
subgraph notif["@memberjunction/notifications"]
NE["NotificationEngine\n(Singleton)"]
TYPES["SendNotificationParams\nNotificationResult\nDeliveryChannels"]
end
subgraph entities["MJ Entity System"]
UNT["UserNotificationTypes"]
UNP["UserNotificationPreferences"]
UNN["UserNotifications\n(In-App Records)"]
end
subgraph comm["@memberjunction/communication-engine"]
CE["CommunicationEngine"]
end
subgraph templates["@memberjunction/templates"]
TE["TemplateEngineServer"]
end
subgraph providers["Delivery Channels"]
INAPP["In-App\n(Database Record)"]
EMAIL["Email\n(via SendGrid)"]
SMS["SMS\n(via Twilio)"]
end
NE -->|reads types| UNT
NE -->|checks prefs| UNP
NE -->|creates| UNN
NE -->|sends via| CE
CE -->|renders| TE
UNN --> INAPP
CE --> EMAIL
CE --> SMS
style notif fill:#7c5295,stroke:#563a6b,color:#fff
style entities fill:#2d6a9f,stroke:#1a4971,color:#fff
style comm fill:#2d8659,stroke:#1a5c3a,color:#fff
style templates fill:#b8762f,stroke:#8a5722,color:#fff
style providers fill:#2d8659,stroke:#1a5c3a,color:#fff
Creates a UserNotification entity record in the database. Synchronous, instant.
Email
Renders the notification type’s EmailTemplateID via TemplateEngineServer, then sends through CommunicationEngine using SendGrid. Fire-and-forget (async).
SMS
Renders the notification type’s SMSTemplateID via TemplateEngineServer, then sends through CommunicationEngine using Twilio. Fire-and-forget (async).