ReadMe

Alerta Gar - Twilio SMS App

This project is a Next.js application that connects to the Twilio API to receive SMS messages, saves the message content into a Supabase database, and displays the messages on the frontend in real-time.

Features

  • Receive SMS Messages: Uses a Twilio virtual phone number to receive incoming SMS messages.

  • Store SMS Data: Saves SMS details (sender, message, timestamp) into a Supabase database.

  • Display Messages: Fetches and displays the stored SMS messages on the frontend.

  • Secure Webhooks: Validates requests using Twilio's x-twilio-signature.

  • Real-time Updates (Optional): Supports real-time message updates using Supabase subscriptions.


Technologies Used

  • Next.js: React-based framework for building web applications.

  • Twilio: Cloud communication platform for handling SMS messages.

  • Supabase: Backend-as-a-service for database and authentication.

  • TypeScript: Strongly-typed JavaScript for better developer experience.

  • ngrok: Tool to expose your local server for webhook testing.

  • Tailwind CSS (Optional): For frontend styling.


Getting Started

Prerequisites

  • Node.js (v16+ recommended)

  • npm

  • Twilio account and virtual phone number

  • Supabase account

Installation

  1. Clone the Repository:

  2. Install Dependencies:

  3. Set Up Environment Variables: Create a .env.local file in the root of your project and add the following:

  4. Set Up Supabase: Create a Supabase project. Add a table named sms_messages (and optional sensors table) with columns matching your SMS data. For example:

  5. Set Up Twilio: Purchase a Twilio phone number that supports SMS. Configure the webhook URL to point to your endpoint (e.g., /api/receive-sms). Use ngrok for local testing if needed.

  6. Start the Development Server:


Usage

  1. Sending an SMS: Send an SMS to your Twilio phone number. The backend /api/receive-sms endpoint will handle the incoming request, validate it, and store the data in Supabase.

  2. Viewing Messages: Open the application in your browser (http://localhost:3000). View the list of received SMS messages on the homepage or relevant dashboard pages.


Project Structure


API Endpoints

Method
Endpoint
Description

POST

/api/receive-sms

Handles incoming SMS messages from Twilio.

GET

/api/sensors

Retrieves sensor data.


Enforce Branch Naming Convention

To maintain consistency and traceability between Jira issues and Git branches, follow this naming convention:

  • feature/ → Used for new features or improvements.

  • bugfix/ → Used to fix identified bugs.

  • hotfix/ → Used for critical fixes that need immediate deployment.

Each branch should be linked to a Jira issue ID (AGT-XXX), ensuring better integration with project tracking and automation tools.

Commit Types

  • feat: Commits that add or remove a new feature to the API or UI

  • fix: Commits that fix a API or UI bug of a preceded feat commit

  • refactor: Commits that rewrite/restructure your code, however do not change any API or UI behaviour

  • perf: Commits that improve performance

  • style: Commits that do not affect the meaning (white-space, formatting, missing semi-colons, etc)

  • test: Commits that add missing tests or correcting existing tests

  • docs: Commits that affect documentation only

  • build: Commits that affect build components like build tool, ci pipeline, dependencies, project version, etc

  • ops: Commits that affect operational components like infrastructure, deployment, backup, recovery, etc

  • chore: Miscellaneous commits that dont fit anyhwere else


Jira & Git Integration

To track branches, commits, and PRs in Jira, integrate with GitHub (or GitLab/Bitbucket):

  1. Go to Jira Settings → Click Apps → Search for GitHub for Jira.

  2. Install the app and authorize Jira to access your GitHub repository.

  3. Ensure your repository (alertagas-twilio-sms) is linked to Jira.

  4. Enable Smart Commits to recognize AGT-XXX in commits and branches.

2. Automate Issue Tracking with Smart Commits

Use Smart Commit messages to automatically update Jira issues based on commits:

#done → Moves issue to "Done" #in-progress → Moves issue to "In Progress" #review → Moves issue to "Code Review"


Deployment

To deploy the project to Google Cloud Run:


Contributing

  1. Fork the repository.

  2. Clone your fork: git clone https://github.com/your-user/alertagas-twilio-sms.git

  3. Create a feature branch: git checkout -b feature/AGT-XXX-new-feature

  4. Make changes and commit: git commit -m "AGT-XXX: Description"

  5. Push to GitHub: git push origin feature/AGT-XXX-new-feature

  6. Create a Pull Request and request a review.


Contact


License

This project is licensed under the MIT License.

Last updated