Skip to content
/ smsdev Public

Test SMS applications without costs, phone numbers, or external dependencies. A complete local development tool that simulates SMS functionality with a web interface.

License

Notifications You must be signed in to change notification settings

pcdkd/smsdev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“± sms-dev

Local SMS development environment - the Mailtrap for SMS

Test SMS applications without costs, phone numbers, or external dependencies. A complete local development tool that simulates SMS functionality with a beautiful web interface.

npm version License: MIT Node.js

✨ Features

  • πŸš€ Zero Setup - Works instantly without configuration
  • πŸ“± Virtual Phone UI - Beautiful dark mode interface for testing
  • πŸ”„ Real-time Updates - WebSocket connections for live message flow
  • πŸͺ Webhook Testing - Forward messages to your application
  • πŸ” Message Search - Find conversations and messages instantly
  • πŸ“Š Performance Testing - Load testing with configurable parameters
  • πŸ€– Conversation Flows - Automated message sequences with conditions
  • πŸ“€ Export Data - Export conversations as JSON or CSV
  • βš™οΈ Flexible Config - File, environment, or CLI configuration
  • 🎨 Developer First - Designed for modern development workflows

πŸš€ Quick Start

Global Installation

# Install globally via npm
npm install -g @relay-works/sms-dev

# Start the development environment
sms-dev start

# Open in browser
# API: http://localhost:4001
# UI: http://localhost:4000

Local Installation

# Install locally in your project
npm install --save-dev @relay-works/sms-dev

# Add to package.json scripts
{
  "scripts": {
    "sms-dev": "sms-dev start"
  }
}

# Run in your project
npm run sms-dev

πŸ“– Usage Examples

Basic SMS Testing

// Your application code
const response = await fetch('http://localhost:4001/v1/messages', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    to: '+1234567890',
    body: 'Hello from my app!'
  })
})

const message = await response.json()
console.log('Message sent:', message.id)

Webhook Testing

# Start with webhook forwarding
sms-dev start --webhook-url http://localhost:3000/webhook/sms

# Your app will receive webhooks for all messages

Configuration File

// sms-dev.config.js
module.exports = {
  apiPort: 4001,
  uiPort: 4000,
  webhookUrl: 'http://localhost:3000/webhook/sms',
  cors: {
    enabled: true,
    origins: ['http://localhost:3000']
  }
}

πŸ› οΈ CLI Commands

Core Commands

sms-dev start              # Start API and UI servers
sms-dev start --no-ui      # Start API only
sms-dev stop               # Stop all servers
sms-dev status             # Check server status
sms-dev config             # Show current configuration

Configuration

sms-dev init               # Generate config file
sms-dev init --json        # Generate JSON config
sms-dev config --config custom.js  # Use custom config

Testing Utilities

# Mock phone management
sms-dev mock-phone create --phone +1234567890 --name "Test User"
sms-dev mock-phone list
sms-dev mock-phone delete --phone +1234567890

# Conversation flows
sms-dev flow create --name "Welcome Flow"
sms-dev flow list
sms-dev flow execute --flow-id flow_123 --phone +1234567890

# Data export
sms-dev export messages --format json --output messages.json
sms-dev export conversations --format csv

# Performance testing
sms-dev perf stats
sms-dev perf load-test --messages 1000 --users 10 --duration 60

πŸ”§ Configuration Options

CLI Options

sms-dev start [options]

Options:
  -p, --port <port>         API server port (default: 4001)
  --ui-port <port>          UI server port (default: 4000)
  -w, --webhook-url <url>   Webhook URL for forwarding
  --cors-origins <origins>  CORS allowed origins
  --no-ui                   Disable UI server
  -v, --verbose             Enable verbose logging
  -c, --config <file>       Configuration file path

Environment Variables

SMS_DEV_API_PORT=4001         # API server port
SMS_DEV_UI_PORT=4000          # UI server port
SMS_DEV_WEBHOOK_URL=...       # Webhook URL
SMS_DEV_CORS_ORIGINS=...      # CORS origins (comma-separated)
SMS_DEV_VERBOSE=true          # Enable verbose logging
SMS_DEV_NO_UI=true            # Disable UI server

Configuration File

// sms-dev.config.js
module.exports = {
  // Server configuration
  apiPort: 4001,
  uiPort: 4000,
  
  // Webhook testing
  webhookUrl: 'http://localhost:3000/webhook/sms',
  
  // CORS configuration
  cors: {
    enabled: true,
    origins: ['*'] // Allow all origins in development
  },
  
  // Logging
  logging: {
    enabled: true,
    level: 'info' // 'debug' | 'info' | 'warn' | 'error'
  }
}

πŸ”Œ API Documentation

Send Message

POST /v1/messages
Content-Type: application/json

{
  "to": "+1234567890",
  "from": "+15551234567",
  "body": "Hello world!"
}

List Messages

GET /v1/messages?limit=20&offset=0&search=hello&status=delivered

Export Messages

GET /v1/messages/export?format=json&phone=1234567890&from_date=2024-01-01

Performance Stats

GET /v1/dev/performance/stats

View Full API Documentation β†’

🎯 Framework Integration

Express.js

import express from 'express'

const app = express()

// Webhook endpoint for sms-dev
app.post('/webhook/sms', express.json(), (req, res) => {
  const { id, to, from, body, status } = req.body
  console.log('SMS received:', { id, to, from, body, status })
  
  // Process your SMS logic here
  
  res.json({ success: true })
})

app.listen(3000)

// Start sms-dev with webhook
// sms-dev start --webhook-url http://localhost:3000/webhook/sms

Next.js

// pages/api/webhook/sms.js
export default function handler(req, res) {
  if (req.method === 'POST') {
    const { id, to, from, body, status } = req.body
    console.log('SMS received:', { id, to, from, body, status })
    
    // Process your SMS logic here
    
    res.status(200).json({ success: true })
  } else {
    res.setHeader('Allow', ['POST'])
    res.status(405).end(`Method ${req.method} Not Allowed`)
  }
}

React Testing

// hooks/useSMSTesting.js
import { useState } from 'react'

export function useSMSTesting() {
  const [messages, setMessages] = useState([])
  
  const sendTestMessage = async (to, body) => {
    const response = await fetch('http://localhost:4001/v1/messages', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ to, body })
    })
    
    const message = await response.json()
    setMessages(prev => [...prev, message])
    return message
  }
  
  return { messages, sendTestMessage }
}

πŸ” Troubleshooting

Port Already in Use

# Check what's using the port
lsof -i :4001

# Use different ports
sms-dev start --port 4002 --ui-port 4003

Permission Issues

# Install with correct permissions
sudo npm install -g @relay-works/sms-dev

# Or use npx without global install
npx @relay-works/sms-dev start

Configuration Issues

# Debug configuration
sms-dev config
sms-dev start --show-config

# Reset configuration
rm sms-dev.config.js
sms-dev init

πŸ“¦ Monorepo Development

If you're working with the sms-dev source code:

# Clone repository
git clone https://github.com/pcdkd/smsdev.git
cd smsdev

# Install dependencies
npm install

# Build packages
npm run build

# Run local development
./apps/sms-dev/dist/cli.js start

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Fork and clone the repository
git clone https://github.com/your-username/smsdev.git
cd smsdev

# Install dependencies
npm install

# Build all packages
npm run build

# Run tests
npm test

# Start development server
npm run dev

πŸ“„ License

MIT Β© Relay

πŸ”— Links


Made with ❀️ by the Relay team

# Test automation - Sun Jun 30 11:08:30 EDT 2025

About

Test SMS applications without costs, phone numbers, or external dependencies. A complete local development tool that simulates SMS functionality with a web interface.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •