VAPI integration
VAPI assistants need phone numbers, and SignalWire supplies them over SIP trunking in both directions. Callers dial your SignalWire number and reach the assistant, and the assistant places calls that show your SignalWire number as caller ID.
Each direction is its own SIP trunk in VAPI and its own SWML script in SignalWire. Set up the one you need, or both. The VAPI side follows VAPI’s own SIP trunk setup guide with SignalWire-specific values.
What you’ll need
- A SignalWire account with at least one phone number (sign up here)
- A VAPI account with API access
- Your VAPI private API key (found in your VAPI dashboard)
- For outbound calls, a password on the SIP Address of your outbound script (set below)
Inbound calls to your assistant
VAPI has to accept calls from SignalWire’s network, and SignalWire has to know which assistant a number belongs to. You create a trunk in VAPI that trusts SignalWire’s IP addresses, register your number with it, and then route the number to VAPI with a SWML script.
Create the inbound SIP trunk in VAPI
Run the API call below to create the trunk, making sure to replace YOUR_VAPI_PRIVATE_KEY with your actual API key.
Save the id from the response - you’ll need this credential ID for the next step.
These IP addresses are current as of this guide’s publication, but SignalWire IPs can change and should be programmatically monitored to avoid any impact on calls. You can gather SignalWire’s latest IPs by performing a DIG or nslookup of sip.signalwire.com.
See our guide on allowing SignalWire IPs through firewalls for more details.
Register your SignalWire phone number
Now register your SignalWire phone number with VAPI using the credential ID from above:
Make sure to replace:
YOUR_VAPI_PRIVATE_KEYwith your actual API key+15551234567with your SignalWire phone number in E.164 format (including the + and country code)YOUR_CREDENTIAL_IDwith the credential ID from the previous step
Assign your assistant
In your VAPI dashboard, find the phone number you just registered and assign it to one of your AI assistants. Configure the inbound settings only. If you also set up outbound calls below, you register the same number a second time against the outbound trunk.
Create the routing script in SignalWire
In your SignalWire dashboard, go to Resources → Add → Script → SWML Script. This script will handle all incoming calls by immediately connecting them to VAPI:
Replace YOUR_CREDENTIAL_ID with the credential ID from the VAPI trunk setup above. The %{call.to} variable ensures VAPI receives the original dialed number, which helps with call routing and analytics.
This SWML script uses the connect method to bridge the incoming call directly to VAPI’s SIP endpoint.
The call happens in real time with no delays. Learn more about SWML in our complete guide.
Connect the script to your phone number
Go to Phone Numbers in your SignalWire dashboard, find your number, and click Edit Settings. Under the voice settings, assign your new SWML script to handle incoming calls.
Test inbound calls
Call your SignalWire phone number. Your VAPI assistant answers within a few seconds. If it doesn’t, the troubleshooting section below covers the common causes.
Outbound calls from your assistant
For outbound calls the roles reverse. SignalWire publishes a SIP Address that VAPI dials, and a SWML script bridges each call onto the public telephone network with your SignalWire number as caller ID. VAPI sends each call to the SIP Address on that script and authenticates with a password you set on the SIP Address.
Create the outbound routing script
In your SignalWire dashboard, go to Resources → Add → Script → SWML Script. This script will handle outbound calls by connecting them through the PSTN:
Replace "+1A-Number-From-Your-Space-here" with an actual phone number from your SignalWire account.
This will be the caller ID shown to people who receive calls from your VAPI assistant.
This SWML script uses the connect method with answer_on_bridge: true to ensure calls connect properly.
The to field uses a regular expression to extract the phone number from VAPI’s SIP format and route it through the PSTN.
Add a SIP Address to your script
After saving your SWML script, add a SIP Address to the script’s Addresses. VAPI sends its outbound calls to this SIP Address:
- Open the SWML script and select its Addresses & Phone Numbers tab.
- Select + Add, then SIP Address.
- On the New SIP Address page, fill out the Domain and Display Name.
- In the Password row, select Set Password and enter a password. VAPI authenticates with it, so keep it for the next step. To change it later, select the address in Addresses & Phone Numbers and use Change Password.
- Select Create.
Keep the user part of the address at its default, *, which accepts any username. VAPI puts the
number it’s calling in the user part, and the script reads it from there.
SignalWire builds the host of the SIP Address from your Space name and the Domain you chose, in
the form <YOUR_SPACE>-<domain>.dapp.signalwire.com, such as test-space-vapi.dapp.signalwire.com.
Note it down for the next step. The Addresses documentation covers SIP Addresses
in more detail.
Create the outbound SIP trunk in VAPI
Run this API call to create the outbound trunk, making sure to replace the placeholder values with your actual configuration:
Make sure to replace:
YOUR_VAPI_PRIVATE_KEY- Your VAPI API keyYOUR_SIP_ADDRESS_HOST- The host of the script’s SIP Address from the previous step (e.g.,test-space-vapi.dapp.signalwire.com)YOUR_SIGNALWIRE_PHONE_NUMBER- Your SignalWire phone number in E.164 format (e.g.,+15551234567)YOUR_SIGNALWIRE_PASSWORD- The password you set on the script’s SIP Address
Save the id from the response - you’ll need this credential ID for the next step.
Register your SignalWire phone number for outbound
Register your SignalWire phone number with VAPI for outbound calling using the credential ID from above:
Replace:
YOUR_VAPI_PRIVATE_KEY- Your VAPI API key+15551234567- Your actual SignalWire phone number in E.164 formatYOUR_CREDENTIAL_ID- The credential ID from the trunk creation step
Assign your assistant for outbound calls
In your VAPI dashboard, find the phone number you just registered and assign it to one of your AI assistants. Configure the outbound settings to specify which assistant should handle outbound calls.
If you’ve already set up inbound calling with the same number, VAPI will indicate this is a duplicate number. This is completely normal and expected - you’re using the same phone number for both inbound and outbound calling with different configurations.
Test outbound calls
Your VAPI assistant can now make outbound calls through SignalWire. The calls will show your SignalWire phone number as the caller ID.
To test your setup, refer to VAPI’s official documentation on testing your SIP trunk for specific instructions on initiating outbound calls.
Troubleshoot the VAPI integration
You can monitor call logs in both platforms. SignalWire shows the call routing, and VAPI shows the assistant interaction details.
Inbound calls aren’t reaching VAPI
Check that your SWML script has the correct credential ID and is assigned to your phone number.
Also, verify that your phone number is set to accept voice calls. Phone numbers must be in E.164
format (+1234567890) with no spaces or special characters.
VAPI can’t connect on inbound calls
Make sure all SignalWire IP addresses are in your VAPI inbound trunk. If SignalWire has added new IP addresses since you created the trunk, you’ll need to update it.
Outbound calls from VAPI fail to authenticate
Double-check that you’re using the password set on the outbound script’s SIP Address. The authentication username should be your phone number in E.164 format.
Outbound calls from VAPI don’t connect
Verify your outbound SWML script has the correct caller ID number and that it’s a valid number from your SignalWire account. Check that the outbound trunk’s gateway is the host of the script’s SIP Address and that VAPI can resolve it.