A comprehensive web-based tool for changing caller ID and placing real-time VoIP calls using Asterisk and VoIP.ms SIP trunking.
- Real-time VoIP calling via Asterisk AMI integration
- Dynamic caller ID setting for outbound calls
- VoIP.ms SIP trunk configuration and management
- Phone number validation (E.164 format)
- RESTful API endpoints for call control
- Call monitoring and channel management
- CLI fallback scripts for direct Asterisk control
- Comprehensive error handling and logging
-
Install dependencies:
npm install
-
Create environment file:
cp .env.example .env
-
Configure your VoIP.ms and Asterisk credentials in
.env:PORT=3000 # Legacy telecom API (optional) TELECOM_API_KEY=your_api_key_here TELECOM_API_URL=https://api.telecom-provider.com/v1 TELECOM_ACCOUNT_SID=your_account_sid_here # VoIP.ms SIP Configuration VOIPMS_SIP_USERNAME=your_voipms_username VOIPMS_SIP_PASSWORD=your_voipms_password VOIPMS_SIP_SERVER=newyork.voip.ms # Asterisk AMI Configuration ASTERISK_AMI_HOST=localhost ASTERISK_AMI_PORT=5038 ASTERISK_AMI_USER=admin ASTERISK_AMI_PASS=your_ami_password
Start the server:
npm startFor development with auto-reload:
npm run devBefore using the VoIP calling features, you need to configure Asterisk with the provided configuration files:
# Copy SIP configuration
sudo cp asterisk-configs/sip.conf /etc/asterisk/sip.conf
# Copy dialplan configuration
sudo cp asterisk-configs/extensions.conf /etc/asterisk/extensions.conf
# Copy AMI configuration
sudo cp asterisk-configs/manager.conf /etc/asterisk/manager.confEdit the configuration files and replace the placeholder variables with your actual credentials:
${VOIPMS_SIP_USERNAME}- Your VoIP.ms SIP username${VOIPMS_SIP_PASSWORD}- Your VoIP.ms SIP password${ASTERISK_AMI_PASS}- Your desired AMI password
sudo systemctl restart asterisk
# or
sudo asterisk -rx "core reload"asterisk -rx "sip show peers"
asterisk -rx "sip show registry"GET /health
POST /api/caller-id/change
Content-Type: application/json
{
"fromNumber": "+1234567890",
"toNumber": "+0987654321",
"newCallerId": "+1111111111"
}
POST /api/caller-id/call
Content-Type: application/json
{
"to": "+15551234567",
"from": "+15559876543",
"context": "outbound",
"timeout": 30000
}
POST /api/caller-id/hangup
Content-Type: application/json
{
"channel": "Local/15551234567@outbound-00000001;1"
}
GET /api/caller-id/channels
GET /api/caller-id/available
Run the test suite:
npm testNote: Make sure the server is running before running tests.
Place calls directly via command line:
# Basic call
./call.sh +15551234567 +15559876543
# Call with custom context
./call.sh +15551234567 +15559876543 outbound
# The script will validate phone numbers and provide detailed output# Check Asterisk status
asterisk -rx "core show channels"
# Check SIP peers
asterisk -rx "sip show peers"
# Originate a call manually
asterisk -rx "channel originate Local/15551234567@outbound extension 15551234567@outbound"-
Firewall Configuration: Ensure proper firewall rules for:
- SIP (UDP 5060)
- RTP (UDP 10000-20000)
- AMI (TCP 5038) - restrict to localhost
-
AMI Security:
- Use strong passwords for AMI users
- Restrict AMI access by IP address
- Consider using fail2ban for brute force protection
-
Let's Encrypt: For production, consider TLS encryption:
# Install certbot and configure SSL sudo certbot --nginx -d yourdomain.com
If running behind NAT, update the SIP configuration:
[general]
externip=your.external.ip.address
localnet=192.168.1.0/255.255.255.0
nat=yesChoose the server closest to your location:
newyork.voip.mschicago.voip.mslosangeles.voip.msmontreal.voip.mstoronto.voip.ms
-
SIP Registration Failed
asterisk -rx "sip show registry" # Check credentials and server settings
-
AMI Connection Failed
# Check AMI is enabled and credentials are correct asterisk -rx "manager show users"
-
Calls Not Connecting
# Check dial plan and SIP peer status asterisk -rx "dialplan show outbound" asterisk -rx "sip show peers"
-
Audio Issues
- Verify RTP port range (10000-20000) is open
- Check NAT configuration
- Test with a SIP client (Zoiper, etc.) first
All phone numbers should be in E.164 format (e.g., +1234567890).
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Express API │────│ Asterisk AMI │────│ VoIP.ms SIP │
│ (Node.js) │ │ (Call Control) │ │ (SIP Trunk) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
│ │ │
┌────▼────┐ ┌────▼────┐ ┌────▼────┐
│ REST │ │ Dial │ │ PSTN │
│ Client │ │ Plan │ │ Network │
└─────────┘ └─────────┘ └─────────┘