Service Layer medium complexity backend
0
Dependencies
0
Dependents
3
Entities
0
Integrations

Description

Evaluates registered trigger rules against current platform state at scheduled intervals to determine which notifications should be fired. Manages the lifecycle of scenario definitions and coordinates with NotificationDispatcher to deliver the correct notification type and channel. Handles both event-driven triggers and time-based conditions such as inactivity thresholds and certification expiry windows.

Feature: Notification Scenarios

notification-scenario-engine

Sources & reasoning

Line 95 documents Blindeforbundet's explicit 10-day uncontacted-assignment reminder requirement - a textbook notification scenario. Line 116 frames HLF's follow-up improvement around scenario-based push messages. Both sources place this in Phase 2 (→ v1.0), matching the blueprint's [v1.0] tag.

  • docs/source/likeperson.md · line 95
    Automatisk påminnelse etter 10 dager dersom kontakt ikke er opprettet.
  • docs/source/likeperson.md · line 116
    Scenariobaserte push-meldinger og kalendersynkronisering.

Responsibilities

  • Evaluate all registered trigger rules against platform state on each scheduled cycle
  • Detect time-based conditions such as days since last contact or days until certification expiry
  • Resolve the appropriate notification type and delivery channel for each matched scenario
  • Coordinate with NotificationDispatcher to fire notifications without duplication
  • Track which scenarios have already fired to prevent repeated alerts for the same condition

Interfaces

evaluateScenarios(): Promise<ScenarioEvaluationResult[]>
registerScenario(scenario: NotificationScenario): Promise<void>
deactivateScenario(scenarioId: string): Promise<void>
getActiveScenarios(): Promise<NotificationScenario[]>
checkScenarioFired(scenarioId: string, entityId: string): Promise<boolean>