Easy.Notifications
1.1.0
See the version list below for details.
dotnet add package Easy.Notifications --version 1.1.0
NuGet\Install-Package Easy.Notifications -Version 1.1.0
<PackageReference Include="Easy.Notifications" Version="1.1.0" />
<PackageVersion Include="Easy.Notifications" Version="1.1.0" />
<PackageReference Include="Easy.Notifications" />
paket add Easy.Notifications --version 1.1.0
#r "nuget: Easy.Notifications, 1.1.0"
#:package Easy.Notifications@1.1.0
#addin nuget:?package=Easy.Notifications&version=1.1.0
#tool nuget:?package=Easy.Notifications&version=1.1.0
Easy.Notifications
Easy.Notifications is a high-performance, asynchronous, and channel-agnostic notification library for .NET 6+.
It is designed for Enterprise applications that need to send notifications (Email, SMS, Chat, Push) without blocking the main execution thread. It leverages System.Threading.Channels to implement a robust "Fire-and-Forget" architecture.
🚀 Features
** Asynchronous & Non-Blocking:** Uses high-performance in-memory queues to dispatch messages instantly.
** Multi-Channel Support:** Unified API for:
Email: SMTP, SendGrid, Mailgun.
SMS / WhatsApp: Twilio, Vonage (Nexmo).
Chat: Slack (Block Kit), Microsoft Teams (Message Cards), Telegram.
Realtime: SignalR (WebSockets).
** Rich Content Support:** - Automatically converts messages to Slack Block Kit structures.
- Renders Microsoft Teams Message Cards with custom colors and sections.
** Modular Architecture:** Add only the providers you need via Dependency Injection.
** Built-in Templating:** Lightweight template engine for dynamic content (
Hello {{Name}}).
Architecture
The library separates the Dispatching logic from the Processing logic to ensure maximum throughput.
Producer: Your Controller calls
INotificationService.SendAsync().Dispatcher: The payload is instantly written to a memory channel. Control returns to your code in microseconds.
Worker: A background service (
BackgroundNotificationWorker) reads from the channel.Provider: The specific provider (e.g.,
SlackProvider,SmtpEmailProvider) executes the external API call safely.
📦 Installation
Install via NuGet Package Manager:
Install-Package Easy.Notifications
Or via .NET CLI:
dotnet add package Easy.Notifications
Configuration
1. appsettings.json
Configure only the providers you intend to use.
{
"NotificationConfiguration": {
"EmailConfiguration": {
"Host": "smtp.example.com",
"Port": 587,
"Username": "apikey",
"Password": "secret-password",
"Sender": "no-reply@example.com",
"SenderDisplayName": "System Alerts",
"EnableSsl": true
},
"TwilioConfiguration": {
"AccountSid": "ACxxxxxxxx...",
"AuthToken": "xxxxxxxx...",
"FromNumber": "+15551234567"
},
"SendGridConfiguration": {
"ApiKey": "SG.xxxxxxxx...",
"SenderEmail": "alert@example.com",
"SenderName": "Alert Bot"
},
"VonageConfiguration": {
"ApiKey": "a1b2c3d4",
"ApiSecret": "xxxxxxxxxxxx",
"Sender": "MyBrand"
},
"MailgunConfiguration": {
"ApiKey": "<MAILGUN_API_KEY>",
"Domain": "<MAILGUN_DOMAIN>",
"SenderEmail": "noreply@example.com",
"SenderName": "Easy Notifications"
},
"TelegramConfiguration": {
"BotToken": "123456:ABC-DEF..."
}
}
}
2. Service Registration (Program.cs)
Register the core services and the specific providers you need.
using Easy.Notifications.Extensions;
var builder = WebApplication.CreateBuilder(args);
// 1. Add Core Services (Dispatcher, Worker)
builder.Services.AddEasyNotifications();
// 2. Add Desired Providers (Modular Registration)
// Email
builder.Services.AddSmtpEmail(builder.Configuration);
// SMS & WhatsApp
builder.Services.AddTwilio(builder.Configuration);
// Chat Apps (Slack, Teams, Telegram)
builder.Services.AddChatProviders(builder.Configuration);
// Realtime
builder.Services.AddSignalRNotifications();
var app = builder.Build();
// 3. Map SignalR Hub (If using Realtime)
app.MapHub<NotificationHub>("/notifications");
app.Run();
Usage
Inject INotificationService into your controllers or business services.
Example 1: Sending Rich Slack & Teams Messages
Send structured messages with colors, headers, and metadata without dealing with complex JSON payloads.
public class AlertController : ControllerBase
{
private readonly INotificationService _notifier;
public AlertController(INotificationService notifier)
{
_notifier = notifier;
}
[HttpPost("alert")]
public async Task<IActionResult> SendAlert()
{
var slackUrl = "https://hooks.slack.com/services/T000/B000/XXXX";
var teamsUrl = "https://your-teams-webhook-url";
var payload = new NotificationPayload
{
Subject = "High CPU Usage Warning 🚨",
Body = "Server **Prod-01** CPU usage is at *98%*. Please investigate immediately.",
Recipients = new List<Recipient>
{
Recipient.Chat(slackUrl, NotificationChannelType.Slack),
Recipient.Chat(teamsUrl, NotificationChannelType.Teams)
},
// Metadata creates "Context" in Slack and "Fact Section" in Teams
Metadata = new Dictionary<string, object>
{
{ "ThemeColor", "FF0000" }, // Red card for Teams
{ "Server", "Linux-Prod-01" },
{ "Region", "US-East-1" },
{ "Time", DateTime.Now.ToString("HH:mm") }
}
};
// Fire-and-Forget
await _notifier.SendAsync(payload);
return Ok("Alert queued.");
}
}
Example 2: Multi-Channel Broadcast (Email + SMS)
var payload = new NotificationPayload
{
Subject = "Welcome {{Name}}",
Body = "Hi {{Name}}, your account is activated.",
TemplateData = new Dictionary<string, string> { { "Name", "John Doe" } },
Recipients = new List<Recipient>
{
Recipient.Email("john@example.com", "John Doe"),
Recipient.Sms("+15550001234"),
Recipient.WhatsApp("+15550001234")
}
};
await _notifier.SendAsync(payload);
Example 3: Real-Time Web Notification (SignalR)
var payload = new NotificationPayload
{
Subject = "Export Complete",
Body = "Your data export is ready to download.",
Recipients = new List<Recipient>
{
Recipient.Client("user-123-id") // Targets a specific user on frontend
}
};
await _notifier.SendAsync(payload);
Supported Providers
| Channel | Provider Class | NuGet Dependency | Notes |
|---|---|---|---|
SmtpEmailProvider |
Built-in | Standard .NET SmtpClient |
|
SendGridProvider |
SendGrid |
Uses SendGrid Web API | |
MailgunProvider |
Microsoft.Extensions.Http |
Uses Mailgun API v3 | |
| SMS | TwilioSmsProvider |
Twilio |
Standard SMS |
| SMS | VonageSmsProvider |
Built-in | Uses Nexmo/Vonage REST API |
TwilioWhatsAppProvider |
Twilio |
Requires WhatsApp Sandbox/Number | |
| Slack | SlackProvider |
Built-in | Uses Incoming Webhooks (Block Kit) |
| Teams | TeamsProvider |
Built-in | Uses Incoming Webhooks (MessageCard) |
| Telegram | TelegramProvider |
Built-in | Uses Telegram Bot API |
| Realtime | SignalRProvider |
Microsoft.AspNetCore.SignalR.Core |
Pushes to connected clients |
Extending
You can easily add your own provider (e.g., Discord, Firebase FCM) by implementing INotificationProvider.
Create a class implementing
INotificationProvider.Define the
SupportedChannel.Implement
SendAsync.Register it in DI:
services.TryAddEnumerable(ServiceDescriptor.Singleton<INotificationProvider, MyCustomProvider>());
Contributing
Contributions and suggestions are welcome. Please open an issue or submit a pull request.
Contact
For questions, contact us via elmin.alirzayev@gmail.com or GitHub.
License
This project is licensed under the MIT License.
© 2025 Elmin Alirzayev / Easy Code Tools
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| .NET Framework | net47 is compatible. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7
- Microsoft.AspNetCore.SignalR (>= 1.2.9)
- Microsoft.Extensions.Http (>= 9.0.7)
- Microsoft.Extensions.Logging (>= 9.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.8)
- SendGrid (>= 9.29.3)
- SendGrid.Extensions.DependencyInjection (>= 1.0.1)
- System.Text.Json (>= 10.0.2)
- Twilio (>= 7.14.2)
- Vonage (>= 8.2.0)
-
.NETFramework 4.8
- Microsoft.AspNetCore.SignalR (>= 1.2.9)
- Microsoft.Extensions.Http (>= 9.0.7)
- Microsoft.Extensions.Logging (>= 9.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.8)
- SendGrid (>= 9.29.3)
- SendGrid.Extensions.DependencyInjection (>= 1.0.1)
- System.Text.Json (>= 10.0.2)
- Twilio (>= 7.14.2)
- Vonage (>= 8.2.0)
-
.NETStandard 2.1
- Microsoft.AspNetCore.SignalR (>= 1.2.9)
- Microsoft.Extensions.Http (>= 9.0.7)
- Microsoft.Extensions.Logging (>= 9.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.8)
- SendGrid (>= 9.29.3)
- SendGrid.Extensions.DependencyInjection (>= 1.0.1)
- System.Text.Json (>= 10.0.2)
- Twilio (>= 7.14.2)
- Vonage (>= 8.2.0)
-
net10.0
- Microsoft.AspNetCore.SignalR (>= 1.2.9)
- Microsoft.Extensions.Http (>= 10.0.2)
- Microsoft.Extensions.Logging (>= 10.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.2)
- SendGrid (>= 9.29.3)
- SendGrid.Extensions.DependencyInjection (>= 1.0.1)
- Twilio (>= 7.14.2)
- Vonage (>= 8.21.0)
-
net6.0
- Microsoft.AspNetCore.SignalR (>= 1.2.9)
- Microsoft.Extensions.Http (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
- SendGrid (>= 9.29.3)
- SendGrid.Extensions.DependencyInjection (>= 1.0.1)
- System.Text.Json (>= 10.0.2)
- Twilio (>= 7.14.2)
- Vonage (>= 6.12.0)
-
net7.0
- Microsoft.AspNetCore.SignalR (>= 1.2.9)
- Microsoft.Extensions.Http (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
- SendGrid (>= 9.29.3)
- SendGrid.Extensions.DependencyInjection (>= 1.0.1)
- System.Text.Json (>= 10.0.2)
- Twilio (>= 7.14.2)
- Vonage (>= 6.12.0)
-
net8.0
- Microsoft.AspNetCore.SignalR (>= 1.2.9)
- Microsoft.Extensions.Http (>= 9.0.7)
- Microsoft.Extensions.Logging (>= 9.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.8)
- SendGrid (>= 9.29.3)
- SendGrid.Extensions.DependencyInjection (>= 1.0.1)
- System.Text.Json (>= 10.0.2)
- Twilio (>= 7.14.2)
- Vonage (>= 8.2.0)
-
net9.0
- Microsoft.AspNetCore.SignalR (>= 1.2.9)
- Microsoft.Extensions.Http (>= 9.0.7)
- Microsoft.Extensions.Logging (>= 9.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.8)
- SendGrid (>= 9.29.3)
- SendGrid.Extensions.DependencyInjection (>= 1.0.1)
- System.Text.Json (>= 10.0.2)
- Twilio (>= 7.14.2)
- Vonage (>= 8.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
-