Kanject.NotificationHub
A multi-channel notification engine — send a ready-made message on a single channel, or publish an event and let the hub resolve templates, channels, scheduling, and cancellation. Eight channels: SMS, email, web, push, in-app, WhatsApp, and webhook.
- Provision NotificationHub into your AWS account
- Register it with
AddNotificationHubServerand injectIHubIngestionManager - Send a content notification and publish an event notification
- Understand the channel model, dispatch priority, and bring-your-own providers
Provision
kanject baas deploy notifications --env dev Register it in your service
Register with AddNotificationHubServer(options => …) from Kanject.NotificationHub.Provider.AwsV2.Extensions, passing a typed AwsHubConfiguration delegate (region, namespace, credentials). A generic AddNotificationHubServer<THubDbContext> overload lets you supply your own data context.
using Kanject.NotificationHub.Provider.AwsV2.Extensions;var builder = WebApplication.CreateBuilder(args);builder.Services.AddNotificationHubServer(options =>{ options.Region = appSettings.AwsRegion; options.Namespace = appSettings.Stage; // per-stage isolation});var app = builder.Build();app.Run(); Send a notification
Inject IHubIngestionManager. There are two entry points: IngestContentNotificationAsync sends a message you've already rendered on one PublishChannel; IngestEventNotificationAsync publishes an event topic + payload and lets the hub resolve templates, channels, and any scheduling on its side.
// Inject IHubIngestionManager — the send surface has two entry points.public class OrderNotifier(IHubIngestionManager hub){ // Content notification: you supply the rendered message + one channel. public Task ShippedAsync(string toEmail) => hub.IngestContentNotificationAsync(new IngestContentNotificationRequest { To = toEmail, Subject = "Your order shipped", Body = "It's on the way — arriving tomorrow.", Channel = PublishChannel.Email, DispatchPriority = NotificationDispatchPriority.Transactional, }); // Event notification: publish an event topic + payload; templates and // channels resolve on the hub side (including scheduling/cancellation). public Task OrderPlacedAsync(JsonDocument payload) => hub.IngestEventNotificationAsync(new IngestNotificationRequest { EventTopic = "order.placed", Payload = payload, });} Scheduling & cancellation
- Delayed / recurring / calendar — scheduled sends via
NotificationScheduleType(Delayed,Recurring,Calendar). - Smart cancellation — a
ScheduleCancellationEventDto { EventTopic, CorrelationId }drops a queued send when a correlated event arrives. - Dispatch priority —
NotificationDispatchPriorityroutes transactional sends through a high-priority queue ahead of bulk.
What you get
- Eight channels —
PublishChannel: SMS, Email, Web, Push, InApp, WhatsApp, Webhook (single-select per content send). - Two send modes — pre-rendered content sends, or event notifications the hub templates and routes.
- Scheduling — delayed, recurring, and calendar sends, with correlated-event cancellation.
- Dispatch priority — separate high- and low-priority outgoing queues.
- Bring your own delivery — implement
IHubDispatchProviderand mark it[NotificationPublisherProvider]to add a channel/provider.
- Provision with
kanject baas deploy notifications, register withAddNotificationHubServer(options => …). - Send via
IHubIngestionManager—IngestContentNotificationAsync(one channel) orIngestEventNotificationAsync(topic + payload). PublishChannelis single-select (8 channels), not a flags bitmask; scheduling/cancellation ride event notifications.- Add delivery providers by implementing
IHubDispatchProvider+[NotificationPublisherProvider].