Express.js API for sending and receiving SMS with Twilio. Ready for deployment on Railway.
- Node.js 18+
- Twilio account with a Messaging Service SID or phone number
- Install dependencies:
npm install
- Copy env and fill values:
cp .env.example .env
# Edit .env with your credentials
- Run locally:
npm run dev
The server listens on PORT (default 3000).
GET /– service infoGET /healthz– health checkPOST /twilio/send– send SMS- JSON body:
{ "to": "+15551234567", "body": "Hello" }
- JSON body:
POST /twilio/webhook– Twilio inbound SMS webhook receiver
- Push this repo to GitHub.
- Create a new Railway project and deploy from your repo.
- Set Environment Variables in Railway:
TWILIO_ACCOUNT_SIDTWILIO_AUTH_TOKENTWILIO_MESSAGING_SERVICE_SIDorTWILIO_PHONE_NUMBER- Optional:
CORS_ORIGIN
- Railway sets
PORTautomatically; the server reads it.
- Secrets are loaded from
.envviadotenvand.envis gitignored. - Java/Maven
target/remains ignored in.gitignorefor the original project artifacts.