This project provides a simple service for pushing WhatsApp notifications using Twilio, RabbitMQ, and OpenTelemetry with a C# ASP.NET Core backend.
- Overview
- Architecture
- Technologies Used
- Setup and Installation
- Running the Project
- Endpoints
- Observability
- Future Enhancements
- License
The WhatsApp Notification Service is composed of two main components:
- API Service: A REST API built with ASP.NET Core that receives requests to send WhatsApp messages and queues them in RabbitMQ.
- Worker Service: A background service that listens to the RabbitMQ queue, picks up messages, and sends them to users via Twilio's WhatsApp API.
The architecture consists of the following components:
- ASP.NET Core Web API: Exposes an endpoint to receive message requests and enqueue them in RabbitMQ.
- RabbitMQ: Acts as a message broker to queue and manage messages.
- Worker Service: Consumes messages from the RabbitMQ queue and sends them to WhatsApp users via Twilio.
- OpenTelemetry: Provides observability for tracing requests and monitoring system behavior.
- C# .NET 8: For building the API and worker services.
- ASP.NET Core: For creating the Web API.
- RabbitMQ: For message queuing and broker services.
- Twilio API: For sending WhatsApp messages.
- OpenTelemetry: For distributed tracing and observability.
- Docker: For containerizing the services.
- .NET 8 SDK
- RabbitMQ
- Docker (optional)
- Twilio Account
git clone https://github.com/Matthew-Oduamafu/whatsapp-notification-sender.git
cd WhatsAppPushNotification
Update the appsettings.json
file in both the API and Worker projects with the following configurations:
{
"TwilioConfig": {
"AccountSid": "ACXXXXXXXX", // Twilio Account SID
"AuthToken": "your_auth_token", // Twilio Auth Token
"PhoneNumber": "your_twilio_phone_number" // Twilio Phone Number
},
"RabbitMqConfig": {
"Host": "localhost",
"QueueName": "WhatsappNotificationQueue"
}
}
Run the following commands in both the WhatsAppNotificationApi
and WhatsAppNotificationWorker
directories:
dotnet add package RabbitMQ.Client
dotnet add package Twilio
dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Instrumentation.AspNetCore
dotnet add package OpenTelemetry.Exporter.Console
Set up a RabbitMQ container using Docker from the docker-compose file in the root directory:
docker-compose up -d
-
Run the API Project
Navigate to the WhatsAppNotificationApi directory and run:
dotnet run
-
Run the Worker Service
Navigate to the WhatsAppNotificationWorker directory and run:
dotnet run