66[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
77[ ![ NuGet] ( https://img.shields.io/badge/NuGet-Available-blue )] ( https://www.nuget.org/ )
88
9- A modern, extensible messaging framework for .NET that provides a unified abstraction layer for various messaging providers including SMS, email, and push notifications. The framework offers strong type safety, comprehensive validation, and flexible connector architecture.
9+ A modern, extensible messaging framework for .NET that provides a unified abstraction layer for various messaging providers including SMS, email, WhatsApp, and push notifications. The framework offers strong type safety, comprehensive validation, and flexible connector architecture.
1010
1111## 🚀 Motivation
1212
13- Modern applications often need to send notifications through multiple channels (SMS, email, push notifications, webhooks). Each provider has different APIs, authentication methods, and message formats. The Deveel Messaging Framework solves this by:
13+ Modern applications often need to send notifications through multiple channels (SMS, email, WhatsApp, push notifications, webhooks). Each provider has different APIs, authentication methods, and message formats. The Deveel Messaging Framework solves this by:
1414
1515- ** Unified API** : Single interface for all messaging providers
1616- ** Type Safety** : Strongly-typed endpoints and configurations prevent runtime errors
1717- ** Extensibility** : Easy to add new providers and message types
1818- ** Validation** : Built-in message and configuration validation
19+ - ** Webhook Support** : Comprehensive webhook handling for message receiving and status updates
1920- ** Testability** : Comprehensive mocking and testing support
2021- ** Performance** : Async/await throughout with efficient resource usage
2122
@@ -25,8 +26,9 @@ Modern applications often need to send notifications through multiple channels (
2526| ---------| -------------| -------|
2627| ` Deveel.Messaging.Abstractions ` | Core messaging abstractions and models | [ ![ NuGet] ( https://img.shields.io/nuget/v/Deveel.Messaging.Abstractions.svg )] ( https://www.nuget.org/packages/Deveel.Messaging.Abstractions/ ) |
2728| ` Deveel.Messaging.Connector.Abstractions ` | Base classes and interfaces for connectors | [ ![ NuGet] ( https://img.shields.io/nuget/v/Deveel.Messaging.Connector.Abstractions.svg )] ( https://www.nuget.org/packages/Deveel.Messaging.Connector.Abstractions/ ) |
28- | ` Deveel.Messaging.Connector.Twilio ` | Twilio SMS connector implementation | [ ![ NuGet] ( https://img.shields.io/nuget/v/Deveel.Messaging.Connector.Twilio.svg )] ( https://www.nuget.org/packages/Deveel.Messaging.Connector.Twilio/ ) |
29+ | ` Deveel.Messaging.Connector.Twilio ` | Twilio SMS & WhatsApp connector implementation | [ ![ NuGet] ( https://img.shields.io/nuget/v/Deveel.Messaging.Connector.Twilio.svg )] ( https://www.nuget.org/packages/Deveel.Messaging.Connector.Twilio/ ) |
2930| ` Deveel.Messaging.Connector.Sendgrid ` | SendGrid email connector implementation | [ ![ NuGet] ( https://img.shields.io/nuget/v/Deveel.Messaging.Connector.Sendgrid.svg )] ( https://www.nuget.org/packages/Deveel.Messaging.Connector.Sendgrid/ ) |
31+ | ` Deveel.Messaging.Connector.Firebase ` | Firebase Cloud Messaging (FCM) push notification connector | [ ![ NuGet] ( https://img.shields.io/nuget/v/Deveel.Messaging.Connector.Firebase.svg )] ( https://www.nuget.org/packages/Deveel.Messaging.Connector.Firebase/ ) |
3032
3133## 🔧 Installation
3234
@@ -43,11 +45,14 @@ dotnet add package Deveel.Messaging.Connector.Abstractions
4345### Install Provider-Specific Connectors
4446
4547``` bash
46- # Twilio SMS connector
48+ # Twilio SMS & WhatsApp connector
4749dotnet add package Deveel.Messaging.Connector.Twilio
4850
4951# SendGrid email connector
5052dotnet add package Deveel.Messaging.Connector.Sendgrid
53+
54+ # Firebase Cloud Messaging (FCM) push notifications
55+ dotnet add package Deveel.Messaging.Connector.Firebase
5156```
5257
5358## 🏁 Quick Start
@@ -98,11 +103,12 @@ if (result.IsSuccess)
98103}
99104```
100105
101- ### 3. SMS Example with Twilio
106+ ### 3. SMS & WhatsApp with Twilio
102107
103108``` csharp
109+ // SMS
104110var smsSchema = new ChannelSchema (" Twilio" , " SMS" , " 2.1.0" )
105- .WithCapabilities (ChannelCapability .SendMessages | ChannelCapability .MessageStatusQuery )
111+ .WithCapabilities (ChannelCapability .SendMessages | ChannelCapability .MessageStatusQuery | ChannelCapability . ReceiveMessages )
106112 .AddParameter (new ChannelParameter (" AccountSid" , ParameterType .String ) { IsRequired = true })
107113 .AddParameter (new ChannelParameter (" AuthToken" , ParameterType .String ) { IsRequired = true , IsSensitive = true })
108114 .AddContentType (MessageContentType .PlainText )
@@ -115,9 +121,56 @@ var smsMessage = new MessageBuilder()
115121 .WithTextContent (" Your verification code is: 123456" )
116122 .Message ;
117123
118- var twilioConnector = new TwilioConnector (smsSchema );
119- await twilioConnector .InitializeAsync (cancellationToken );
120- var smsResult = await twilioConnector .SendMessageAsync (smsMessage , cancellationToken );
124+ // WhatsApp Business
125+ var whatsAppSchema = new ChannelSchema (" Twilio" , " WhatsApp" , " 2.1.0" )
126+ .WithCapabilities (
127+ ChannelCapability .SendMessages |
128+ ChannelCapability .ReceiveMessages |
129+ ChannelCapability .MessageStatusQuery |
130+ ChannelCapability .Templates |
131+ ChannelCapability .MediaAttachments )
132+ .AddParameter (new ChannelParameter (" AccountSid" , ParameterType .String ) { IsRequired = true })
133+ .AddParameter (new ChannelParameter (" AuthToken" , ParameterType .String ) { IsRequired = true , IsSensitive = true })
134+ .AddContentType (MessageContentType .PlainText )
135+ .AddContentType (MessageContentType .Template )
136+ .AddContentType (MessageContentType .Media )
137+ .AllowsMessageEndpoint (EndpointType .PhoneNumber );
138+
139+ var whatsAppMessage = new MessageBuilder ()
140+ .WithId (" whatsapp-notification-001" )
141+ .WithPhoneSender (" whatsapp:+1234567890" )
142+ .WithPhoneReceiver (" whatsapp:+0987654321" )
143+ .WithTextContent (" Hello from WhatsApp Business!" )
144+ .Message ;
145+ ```
146+
147+ ### 4. Push Notifications with Firebase
148+
149+ ``` csharp
150+ var firebaseSchema = new ChannelSchema (" Firebase" , " Push" , " 1.0.0" )
151+ .WithCapabilities (
152+ ChannelCapability .SendMessages |
153+ ChannelCapability .BulkMessaging |
154+ ChannelCapability .Templates |
155+ ChannelCapability .HealthCheck )
156+ .AddParameter (new ChannelParameter (" ProjectId" , ParameterType .String ) { IsRequired = true })
157+ .AddParameter (new ChannelParameter (" ServiceAccountKey" , ParameterType .String ) { IsRequired = true , IsSensitive = true })
158+ .AddContentType (MessageContentType .PlainText )
159+ .AllowsMessageEndpoint (EndpointType .DeviceId )
160+ .AllowsMessageEndpoint (EndpointType .Topic );
161+
162+ var pushMessage = new MessageBuilder ()
163+ .WithId (" push-notification-001" )
164+ .WithDeviceReceiver (" device-token-123" )
165+ .WithTextContent (" You have a new message!" )
166+ .WithProperty (" Title" , " New Message" )
167+ .WithProperty (" ImageUrl" , " https://example.com/notification-image.png" )
168+ .WithProperty (" ClickAction" , " OPEN_MESSAGE" )
169+ .Message ;
170+
171+ var firebaseConnector = new FirebasePushConnector (firebaseSchema );
172+ await firebaseConnector .InitializeAsync (cancellationToken );
173+ var pushResult = await firebaseConnector .SendMessageAsync (pushMessage , cancellationToken );
121174```
122175
123176## 🎯 Core Features
@@ -130,6 +183,8 @@ Use the `EndpointType` enumeration for type-safe endpoint configuration:
130183// Type-safe endpoint creation
131184var emailEndpoint = Endpoint .EmailAddress (" user@example.com" );
132185var phoneEndpoint = Endpoint .PhoneNumber (" +1234567890" );
186+ var deviceEndpoint = Endpoint .DeviceId (" firebase-device-token" );
187+ var topicEndpoint = Endpoint .Topic (" news-updates" );
133188var webhookEndpoint = Endpoint .Url (" https://api.example.com/webhook" );
134189
135190// Builder pattern with type safety
@@ -148,15 +203,59 @@ Support for various content types and templating:
148203// HTML content
149204 .WithHtmlContent (" <h1>Welcome</h1><p>{{username}}, thanks for joining!</p>" )
150205
151- // Template content with parameters
206+ // Template content with parameters (WhatsApp Business, Firebase)
152207 .WithTemplateContent (" welcome-template" , new { username = " John" , company = " Acme Corp" })
153208
209+ // Media content with attachments
210+ .WithMediaContent (" https://example.com/image.jpg" , " image/jpeg" , " Welcome Image" )
211+
154212// Multipart content with attachments
155213 .WithMultipartContent (content => content
156214 .AddTextPart (" Please find the report attached." )
157215 .AddAttachment (" report.pdf" , pdfBytes , " application/pdf" ))
158216```
159217
218+ ### Webhook Support for Message Receiving
219+
220+ The framework now includes comprehensive webhook support for receiving messages and status updates:
221+
222+ ``` csharp
223+ // Receive incoming messages via webhook
224+ public class MessageWebhookController : ControllerBase
225+ {
226+ [HttpPost (" webhook/twilio/sms" )]
227+ public async Task <IActionResult > ReceiveSms ([FromForm ] Dictionary <string , string > formData )
228+ {
229+ var messageSource = MessageSource .FromFormData (formData );
230+ var result = await _twilioConnector .ReceiveMessagesAsync (messageSource , cancellationToken );
231+
232+ if (result .IsSuccess )
233+ {
234+ foreach (var message in result .Value .Messages )
235+ {
236+ await ProcessIncomingMessage (message );
237+ }
238+ }
239+
240+ return Ok ();
241+ }
242+
243+ [HttpPost (" webhook/twilio/status" )]
244+ public async Task <IActionResult > ReceiveStatus ([FromForm ] Dictionary <string , string > formData )
245+ {
246+ var messageSource = MessageSource .FromFormData (formData );
247+ var result = await _twilioConnector .ReceiveMessageStatusAsync (messageSource , cancellationToken );
248+
249+ if (result .IsSuccess )
250+ {
251+ await ProcessStatusUpdate (result .Value );
252+ }
253+
254+ return Ok ();
255+ }
256+ }
257+ ```
258+
160259### Connector Capabilities
161260
162261Declare and validate connector capabilities:
@@ -165,14 +264,33 @@ Declare and validate connector capabilities:
165264var schema = new ChannelSchema (" Provider" , " Type" , " 1.0.0" )
166265 .WithCapabilities (
167266 ChannelCapability .SendMessages | // Can send messages
168- ChannelCapability .ReceiveMessages | // Can receive messages
267+ ChannelCapability .ReceiveMessages | // Can receive messages via webhooks
169268 ChannelCapability .MessageStatusQuery | // Can track delivery status
170269 ChannelCapability .BulkMessaging | // Supports batch operations
171270 ChannelCapability .Templates | // Supports templating
172271 ChannelCapability .MediaAttachments | // Supports file attachments
173272 ChannelCapability .HealthCheck ) // Provides health monitoring
174273 ```
175274
275+ ### Batch Processing and Performance
276+
277+ ```csharp
278+ // Send multiple messages efficiently
279+ var batch = new MessageBatch (messages );
280+ var batchResult = await connector .SendBatchAsync (batch , cancellationToken );
281+
282+ // Firebase multicast for efficient push notifications
283+ var tokens = new [] { " token1" , " token2" , " token3" };
284+ var multicastMessages = tokens .Select (token =>
285+ new MessageBuilder ()
286+ .WithDeviceReceiver (token )
287+ .WithTextContent (" Broadcast message" )
288+ .Message );
289+
290+ var batch = new MessageBatch (multicastMessages );
291+ var result = await firebaseConnector .SendBatchAsync (batch , cancellationToken );
292+ ```
293+
176294### Error Handling and Results
177295
178296Comprehensive error handling with detailed result objects:
@@ -208,13 +326,13 @@ public class CustomConnector : ChannelConnectorBase
208326 return ConnectorResult <bool >.Success (true );
209327 }
210328
211- protected override async Task <ConnectorResult <MessageResult >> SendMessageCoreAsync (
329+ protected override async Task <ConnectorResult <SendResult >> SendMessageCoreAsync (
212330 IMessage message , CancellationToken cancellationToken )
213331 {
214332 // Implement your message sending logic
215333 var messageId = await SendToProvider (message );
216- return ConnectorResult <MessageResult >.Success (
217- new MessageResult ( messageId , MessageStatus . Sent ));
334+ return ConnectorResult <SendResult >.Success (
335+ new SendResult ( message . Id , messageId ));
218336 }
219337
220338 // Implement other abstract methods...
@@ -230,6 +348,35 @@ public class CustomConnector : ChannelConnectorBase
230348- ** [ Endpoint Type Safety Guide] ( docs/EndpointType-Usage.md ) ** - Working with typed endpoints
231349- ** [ Migration Guide] ( docs/migration-guide.md ) ** - Upgrading from previous versions
232350
351+ ## 🌟 Latest Features & Improvements
352+
353+ ### Firebase Cloud Messaging Support
354+ - ** NEW** : Complete Firebase Cloud Messaging (FCM) connector
355+ - ** Push Notifications** : Device tokens and topic messaging
356+ - ** Multicast Support** : Efficient batch delivery to multiple devices
357+ - ** Platform-Specific** : Android, iOS (APNS), and Web Push configurations
358+ - ** Rich Notifications** : Images, actions, and custom data payloads
359+
360+ ### Enhanced WhatsApp Business Integration
361+ - ** Webhook Support** : Complete JSON and form-data webhook handling
362+ - ** Message Receiving** : Incoming message processing with WhatsApp-specific fields
363+ - ** Status Updates** : Real-time delivery status tracking including read receipts
364+ - ** Interactive Elements** : Button responses, list selections, and template interactions
365+ - ** Business Features** : Profile names, business display names, and verified accounts
366+ - ** Media Support** : Images, documents, audio, and video attachments
367+
368+ ### Improved Message Processing
369+ - ** Batch Operations** : Efficient bulk message sending across all connectors
370+ - ** Status Tracking** : Comprehensive message status queries and webhook updates
371+ - ** Template Support** : WhatsApp Business templates and Firebase notification templates
372+ - ** Content Types** : Enhanced support for media, templates, and multipart content
373+
374+ ### Performance & Reliability
375+ - ** Connection Pooling** : Optimized HTTP client usage
376+ - ** Health Monitoring** : Built-in health checks for all connectors
377+ - ** Error Resilience** : Improved error handling and retry mechanisms
378+ - ** Resource Management** : Better async patterns and disposal handling
379+
233380## 🔗 GitHub Packages
234381
235382This project publishes packages to both NuGet.org and GitHub Packages. To use GitHub Packages:
@@ -251,15 +398,16 @@ dotnet add package Deveel.Messaging.Abstractions --source github-deveel
251398
252399## 🧪 Testing
253400
254- The framework includes comprehensive test suites:
401+ The framework includes comprehensive test suites with over 500 tests :
255402
256403``` bash
257404# Run all tests
258405dotnet test
259406
260- # Run tests for specific project
407+ # Run tests for specific connectors
261408dotnet test test/Deveel.Messaging.Abstractions.XUnit
262409dotnet test test/Deveel.Messaging.Connector.Twilio.XUnit
410+ dotnet test test/Deveel.Messaging.Connector.Firebase.XUnit
263411
264412# Run with coverage
265413dotnet test --collect:" XPlat Code Coverage"
@@ -271,7 +419,7 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
271419
272420### Development Requirements
273421
274- - ** .NET 8.0 SDK** or later
422+ - ** .NET 8.0 SDK** or later (.NET 9.0 recommended)
275423- ** Visual Studio 2022** or ** VS Code** with C# extension
276424- ** Git** for source control
277425
0 commit comments