The TwilioCommHub is a Spring Boot application designed to facilitate SMS communication through the Twilio API. It provides functionality for sending bulk SMS, managing message templates, and logging message statuses. The application incorporates features such as JWT-based authentication, Swagger API documentation, and Prometheus metrics for monitoring.
- Send SMS: Send SMS to individual recipients or in bulk.
- Message Templates: Create and manage reusable message templates with placeholder support.
- Webhook Integration: Update message status via webhooks from Twilio.
- Rate Limiting and Load Balancing: Built-in support for rate limiting and load balancing using Spring Cloud Gateway.
- Monitoring: Expose application metrics for Prometheus monitoring.
- Authentication: Secure endpoints using JWT authentication.
- Spring Boot: Framework for building the application.
- Twilio SDK: For SMS communication.
- Spring Data JPA: For database interactions.
- H2 Database: For in-memory database during development (changeable to MySQL for production).
- JUnit & Mockito: For unit and integration testing.
- Swagger: For API documentation.
- Prometheus: For monitoring metrics.
- Java 17 or higher
- Maven
- Twilio Account (for API credentials)
-
Clone the repository:
git clone https://github.com/chandrakanthrck/TwilioCommHub.git
-
Navigate to the project directory:
cd twilio-communication -
Update
application.propertieswith your Twilio credentials:twilio.account.sid=your_twilio_account_sid twilio.auth.token=your_twilio_auth_token twilio.phone.number=your_twilio_phone_number
-
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
- POST
/api/authenticate- Request Body:
{ "username": "your_username", "password": "your_password" } - Response: JWT token for authentication.
- Request Body:
-
POST
/api/v1/sms/send- Request Parameters:
to,message - Sends an SMS to the specified recipient.
- Request Parameters:
-
POST
/api/sms/send/bulk- Request Parameters:
to(list of recipients),message,scheduledTime(optional) - Sends bulk SMS or schedules messages.
- Request Parameters:
-
POST
/api/template/create- Request Parameters:
name,templateContent - Creates a new message template.
- Request Parameters:
-
POST
/api/template/send- Request Parameters:
templateName,to,params(placeholders) - Sends an SMS using a specified template.
- Request Parameters:
- POST
/api/webhook/sms-status- Request Parameters:
MessageSid,MessageStatus - Updates the status of a sent SMS.
- Request Parameters:
Run the test suite with Maven:
mvn testPrometheus metrics are available at /actuator/prometheus. Configure Prometheus to scrape this endpoint for monitoring.
Swagger documentation is available at /swagger-ui.html once the application is running.
Feel free to open issues or submit pull requests for improvements or bug fixes!
This project is licensed under the MIT License.