Mapping Numbers
Mapping Numbers
Connect phone numbers to your agent using SignalWire’s SWML Script resources.
Overview
SignalWire uses SWML Script resources to connect phone numbers to your agent. When a call comes in, SignalWire fetches SWML from your agent’s URL and executes it.

Step 1: Create a SWML Script Resource
- Log in to SignalWire dashboard
- Navigate to My Resources in the left sidebar
- Click Script
- Click New SWML Script
- Fill in the fields:
- Name: Give your script a name (e.g., “my-agent”)
- Handle Calls Using: Select External URL
- Primary Script URL: Enter your agent URL with credentials
- Format:
https://user:pass@your-domain.com/agent
- Format:
- Click Create

Step 2: Add a Phone Number or Address
After creating the script, you’ll see the resource configuration page:

- Click the Addresses & Phone Numbers tab
- Click + Add
- Choose your address type:
- Phone Number: For receiving calls from regular phones (PSTN)
- SIP Address: For receiving SIP calls
- Alias: For referencing this resource by a custom name
- Follow the prompts to select or purchase a phone number
- Your number is now connected to your agent!

Step 3: Test Your Setup
- Ensure your agent is running locally
- Ensure ngrok is running (if using tunneling)
- Call your SignalWire phone number
- Hear your agent respond!
URL Format
Your agent URL structure depends on your setup:
Single Agent:
Multiple Agents:
With Authentication (recommended):
Using ngrok for Development
For a static URL that doesn’t change on restart:
Basic Authentication
The SDK automatically generates authentication credentials on startup:
For persistent credentials, set environment variables:
In SignalWire, use URL with credentials:
Multi-Agent Server
Run multiple agents on one server:
Create a separate SWML Script resource for each agent:
Fallback URL
Configure a fallback for errors:
Fallback triggers on:
- Connection timeout
- HTTP 5xx errors
- Invalid SWML response
Troubleshooting
Common Issues
Test Checklist
Verification Checklist
Before going live:
- Agent is deployed and running
- HTTPS URL is accessible
- URL returns valid SWML on POST request
- Basic auth is configured
- SWML Script resource created in SignalWire
- Phone number added to SWML Script resource
- Test call completes successfully