Connect a Twilio Number through SIP
Connecting a Twilio number as an External SIP number lets your Versafy Voice Agent answer calls to that number and use it as the caller number for outgoing calls. This is useful when you want to keep the number and call routing in your own Twilio account while using Versafy as an AI phone service.
For the regular Twilio connection without an External SIP trunk, use Connect a Twilio Account and Phone Number. It supports complete inbound flows with operators, schedules, announcements, and voicemail.
This setup supports:
- inbound calls from the Twilio number to one Versafy Voice Agent;
- individual outbound calls from a Voice Agent;
- outbound Campaigns, when available for your workspace;
- call history in Call Logs & Recordings.
External SIP inbound-flow limitation: An External SIP number can be assigned only to an active AI Only Inbound Call Flow without human handover. If callers need operator routing, business-hours branches, announcements, or voicemail, use Versafy’s native Twilio connection instead. See Inbound Call Flows.
Before you begin
Prepare the following:
- a Twilio account with permission to buy numbers and manage Elastic SIP Trunks;
- a Twilio project or subaccount that will own both the number and trunk;
- permission to manage Phone Numbers and Inbound Call Flows in Versafy;
- an active Voice Agent for inbound and outbound calls;
- a password manager for the SIP trunk username and password.
Twilio trial accounts restrict phone-number ownership and outbound destinations. Upgrade the Twilio account before production use and review Twilio’s trial-account restrictions .
Setup overview
You will complete the connection in this order:
- Buy a voice-capable number in Twilio.
- Create a Twilio Elastic SIP Trunk.
- Configure the trunk’s Termination settings for outbound calls.
- Start importing the number in Versafy and copy its inbound SIP URI.
- Add that URI to the trunk’s Origination settings for inbound calls.
- Associate the Twilio number with the trunk.
- Assign the External SIP number to an AI Only Inbound Call Flow.
- Test inbound and outbound calls.
1. Buy a voice-capable number in Twilio
Buying a dedicated number gives customers a public number to call and gives your Voice Agent an approved caller number for outbound calls.
- Sign in to the Twilio Console and select the project or subaccount you intend to use.
- Open Products & Services → Numbers & Senders → Phone Numbers.
- Select Set up a new phone number.
- Choose the country and number type, then require the Voice capability in the search filters.
- Select a number, review Twilio’s recurring and usage charges, and complete the purchase.
- Complete any identity, address, or regulatory registration Twilio requests for that country and number type.
- Copy the purchased number in international E.164 format, including
+and the country code—for example,+12025550123.
Twilio’s interface can vary by account. See Twilio’s current phone-number setup guide if the labels in your Console differ.
2. Create an Elastic SIP Trunk
The trunk is the two-way connection between Twilio and Versafy. One side sends incoming calls to your Voice Agent; the other lets the Voice Agent place calls through your Twilio account.
- In Twilio Console, open Products & Services → Elastic SIP Trunking → Manage → Trunks.
- Select Create New Trunk.
- Enter a recognizable Friendly Name, such as
Versafy Sales Line. - Save the trunk.
Keep the trunk open in one browser tab and Versafy open in another. Twilio’s Elastic SIP Trunking guide explains the current Console sections and terminology.
3. Configure Twilio Termination for outbound calls
Termination lets Versafy send a call to Twilio, which then connects it to the customer’s destination number.
- Open the new trunk’s Termination section.
- Create a unique Termination SIP URI, such as
versafy-sales.pstn.twilio.com. - Copy the complete hostname. You will enter it in Versafy later without
sip:or a port. - In Authentication, create a Credential List.
- Add a new SIP username and a strong, unique password to the list.
- Associate that Credential List with this trunk and save the Termination settings.
Use the SIP Credential List username and password in Versafy—not your Twilio Account SID, Auth Token, or Console password. Twilio requires a Termination URI plus at least one authentication method before the trunk can place outbound calls.
If you will call international destinations, enable only the countries your business needs under Twilio’s Voice geographic permissions. See Twilio’s geographic-permissions guide .
4. Import the number into Versafy
Importing makes the Twilio-owned number available to Versafy without connecting the complete Twilio account.
Navigation: Open Phone → Phone Numbers, select the Numbers tab, then select Add external number (via SIP).
-
Enter a clear Label, such as
Twilio Sales. -
Enter the purchased Phone number in E.164 format, including
+and the country code. -
Expand Inbound Configuration.
-
Under Inbound routing / Origination URI, copy the complete SIP URI. Keep it unchanged; you will paste it into Twilio in the next section.
-
Keep Media Encryption set to Allowed for the initial connection.
-
Leave the optional inbound number filters, source-address filters, domain list, header mappings, and authentication fields unchanged unless your telephony administrator has a specific policy for them.
-
Expand Outbound Configuration and enter:
- Address: the Twilio Termination hostname, such as
versafy-sales.pstn.twilio.com. Do not includesip:or a port. - Transport: TCP (recommended).
- Media Encryption: Disabled.
- SIP Trunk Username: the username from the Twilio Credential List.
- SIP Trunk Password: the password from the same Twilio Credential List.
- Address: the Twilio Termination hostname, such as
-
Leave optional outbound headers and codecs empty for the initial setup.
-
Select Import.
Do not enable Twilio Secure Trunking for this TCP setup. Secure Trunking requires matching TLS and encrypted-media settings on both sides and will reject a connection that uses the settings above.
5. Configure Twilio Origination for inbound calls
Origination tells Twilio where to send a call when a customer dials your purchased number.
- Return to the trunk in Twilio Console and open Origination.
- Select Add new Origination URI.
- Enter a Friendly Name, such as
Versafy inbound. - Paste the complete SIP URI copied from Versafy. It includes the phone number, host, port, and
transport=tcpsetting. - Keep the URI Enabled.
- For a single URI, keep Twilio’s default priority and weight values.
- Save the Origination settings.
Do not replace the number inside the URI, remove transport=tcp, change the scheme to sips:, or paste the Twilio Termination hostname here. Twilio documents Origination URI behavior in its Elastic SIP Trunking configuration guide .
6. Associate the Twilio number with the trunk
Associating the number activates the trunk as the number’s incoming voice route.
Routing change: Associating the number with this trunk replaces its previous incoming voice configuration in Twilio. Confirm that the number is not serving another production application before continuing.
- Open the trunk’s Numbers section.
- Select Associate a Number with this Trunk.
- Choose the number you purchased and confirm the association.
- Verify that the number appears in the trunk’s Numbers list.
If Twilio instead opens the number’s configuration page, choose SIP Trunking for incoming Voice calls, select this trunk, and save.
7. Assign an AI Only Inbound Call Flow
The inbound flow chooses which Voice Agent answers this number.
- In Versafy, open Phone → Phone Numbers → Inbound Call Flows.
- Create a flow using the AI Only template.
- Select the imported External SIP number and the Voice Agent that should answer.
- Review, create, and activate the flow.
- Return to the Numbers tab and confirm that the number shows Inbound Call Flow Attached and the intended flow name.
If you created the flow before importing the number, find the number under Numbers, choose Connect to an Inbound Call Flow, and select an active AI Only flow.
8. Test both call directions
Testing both directions confirms that the number, trunk, authentication, and Versafy assignments work together.
Test inbound calls
- Call the Twilio number from a phone outside the Twilio account.
- Confirm that the expected Voice Agent answers with the correct opening message.
- Ask one normal test question, then end the call.
- Open Phone → Call Logs & Recordings and confirm that the call appears.
Test outbound calls
- Open Phone → Voice Agents.
- Find the active agent and select Make a call.
- Select the imported Twilio number as the caller number.
- Enter a test destination in E.164 format and confirm the call.
- Answer the call and verify two-way audio.
- Check Call Logs & Recordings before repeating a failed or unclear attempt.
You can also review Elastic SIP Trunking → Logs in Twilio. Twilio provides additional trunk checks in Test your Elastic SIP Trunk .
Troubleshooting
The External SIP number does not appear for outbound calls
Confirm that the import completed, the number shows Outbound enabled under Phone → Phone Numbers → Numbers, and the Voice Agent is active. Open Edit on the External number and check the outbound Address and credentials.
Outbound calls fail with an authentication error
Confirm that the Credential List is attached to the same Twilio trunk and that Versafy’s SIP Trunk Username and SIP Trunk Password exactly match it. Do not use Twilio account credentials.
Outbound calls fail before ringing
Check that:
- Address contains only the Twilio Termination hostname;
- the destination includes
+and its country code; - Twilio permits calls to that destination country;
- a trial account is calling a Twilio-verified destination;
- the Twilio number remains owned by the same project or subaccount as the trunk.
Incoming calls do not reach Versafy
Confirm that the Twilio number is associated with the correct trunk, the Origination URI is enabled and exactly matches the value copied from Versafy, and the External number is assigned to an active AI Only flow.
No flow is available for the External SIP number
Only active AI Only flows without human handover are eligible. Create or activate that type of flow, or use the native Twilio connection if you need a more complex caller journey.
The call connects but audio is missing or one-way
Confirm that Twilio Secure Trunking is disabled for this setup and that the Versafy media-encryption settings match this guide. If you restricted Allowed Source IP Addresses, include all current Twilio signaling ranges rather than only one region; review Twilio’s current SIP Trunking IP address list .
If Twilio reports an unsupported-media error, edit the External SIP number and add PCMU/8000 or PCMA/8000 under Enabled Codecs. Twilio’s trunk troubleshooting guide lists the codecs it accepts.
You need to change the imported phone number
You can edit its label and SIP settings, but not the E.164 number itself. Disconnect it from any flow, delete the External SIP number from Versafy, and import the correct number again. Deleting it from Versafy does not release the number from your Twilio account.