Overview
This guide explains how to connect your Twilio account to Smallest AI using Elastic SIP Trunking. This allows you to use your existing Twilio phone numbers with Smallest AI’s voice agents.Prerequisites
Before you begin, make sure you have:- An active Twilio account
- Access to the Twilio Console
- Phone numbers in your Twilio account (or ability to purchase new ones)
Step 1: Create an Elastic SIP Trunk
- Log in to the Twilio Console
- Navigate to Elastic SIP Trunking → Trunks
- Click Create new trunk
- Give your trunk a descriptive name (e.g., “Smallest AI Trunk”)
- Click Create to save your trunk
Step 2: Configure Termination (Outbound Calls)
Termination settings control how outbound calls from Smallest AI are sent to Twilio.Set Up Termination URI
- In your trunk, click on the Termination tab
- Create a Termination SIP URI (e.g.,
mycompany.pstn.twilio.com
) - Choose a localized URI close to your region for optimal call quality:
- For US: Choose a US-based URI
- For EU: Choose an EU-based URI
- For APAC: Choose an APAC-based URI
Configure Authentication
Choose one of the following authentication methods:Option 1: IP Whitelisting
Since Smallest AI doesn’t currently have a fixed IP range:- In the IP Access Control Lists section, click Create new IP ACL
- Add
0.0.0.0/0
to allow all IPs (temporary workaround)
Using 0.0.0.0/0 allows connections from any IP address. For production use, consider using credential-based
authentication instead for better security.
Option 2: Credential-Based Authentication (Recommended)
- Scroll down to the Credentials section
- Click Create credential list
- Give it a name (e.g., “Smallest AI Credentials”)
- Click Create
- Inside the credential list, click Add credential
- Enter a Username and Password
- Save the credentials
- Make note of both the username and password - you’ll need these when importing the number on Smallest AI
The “friendly name” shown in Twilio is NOT the username. Use the actual credential username you created, not
the friendly name of the credential list.
Enable the Credential List
- Go back to your trunk’s Termination tab
- Under Authentication, select your credential list
- Save your changes
Step 3: Configure Origination (Inbound Calls)
Origination settings control how inbound calls to your Twilio numbers are routed to Smallest AI.- In your trunk, click on the Origination tab
- Click Add new Origination URI
- Enter Smallest AI’s SIP server:
- Set Priority to
10
and Weight to10
- Click Add
- Save your changes
Step 4: Assign Numbers to the Trunk
Now you need to connect your phone numbers to the SIP trunk.For Existing Numbers
- Navigate to Phone Numbers → Manage → Active Numbers in Twilio Console
- Click on the phone number you want to use with Smallest AI
- Scroll down to Voice Configuration
- Under Configure With, select SIP Trunk
- In the SIP Trunk dropdown, select your newly created trunk
- Click Save
For New Numbers
- In the Twilio Console, go to Phone Numbers → Buy a Number
- Search for and purchase your desired number
- During setup, configure it to use your SIP trunk
- Or follow the “For Existing Numbers” steps above
Step 5: Import Numbers on Smallest AI
Now that your Twilio trunk is configured, you can import your numbers into Smallest AI.- Navigate to Phone Numbers in your Smallest AI dashboard
- Click Buy Numbers button
- Select the Import SIP Number tab
-
Fill in your number details:
-
Phone Number: Your Twilio number in E.164 format
- Example:
+12025551234
for a US number - Example:
+442071234567
for a UK number
- Example:
-
SIP Termination URL: Your Termination SIP URI from Step 2
- Example:
sip:mycompany.pstn.twilio.com
- Make sure there are NO trailing spaces
- Example:
-
Display Name (Optional): A friendly name for this number
- Example: “Customer Support Line”
-
Username: Your SIP credential username (if using credential-based auth)
- Use the actual username, NOT the friendly name of the credential list
- Password: Your SIP credential password (if using credential-based auth)
-
Phone Number: Your Twilio number in E.164 format
- Copy the SIP Origination URL shown (this should already be configured in Step 3)
- Click Add Custom Number
Make sure the phone number you enter matches exactly with the number in your Twilio account, including the
country code and format.
Step 6: Test Your Setup
After importing your number:- Go to your agents in Smallest AI dashboard
- Assign the imported Twilio number to one of your agents
- Make a test inbound call to your Twilio number
- Verify that the call connects to your AI agent
- Test an outbound call from your agent
- Verify audio quality in both directions
Troubleshooting
Inbound Works, But Outbound Fails
This is a common issue. Check the following: Verify Termination SIP URI:- Make sure there are NO trailing spaces in your URI
- Use the full URI format:
sip:mycompany.pstn.twilio.com
- Don’t include
https://
or other protocols
- Use a localized URI near your geographic region
- If calls are made from the US, use a US-based Twilio URI
- This improves latency and call quality
- Double-check your SIP username and password
- Remember: the “friendly name” in Twilio is NOT the username
- Use the actual credential username you created
- If using IP whitelisting with 0.0.0.0, make sure it’s properly saved
- If using credentials, ensure they’re enabled on your trunk
Unable to Call International Numbers
Twilio restricts international calling by default:- In Twilio Console, search for Voice Geographic Permissions
- Select your account or specifically Elastic SIP Trunking
- Review the list of countries
- Enable the countries you want to dial
- Click Save
International calling permissions may take a few minutes to take effect. Wait 5-10 minutes before testing
again.
One-Way Audio Issues
If one party can hear but the other cannot:- Verify your firewall allows RTP traffic
- Check that media encryption (SRTP) settings match
- Ensure your Twilio trunk doesn’t have restrictive NAT settings
- Contact Smallest AI support if the issue persists
Authentication Errors
“401 Unauthorized” or “403 Forbidden” errors:- Verify credentials are entered correctly in Smallest AI
- Check that credentials are enabled on your Twilio trunk
- Ensure the credential list is attached to your trunk’s Termination tab
- Verify the Termination SIP URI is correct
- Check that the URI is reachable and properly formatted
Call Quality Issues
Choppy or robotic audio:- Choose a Twilio URI closer to your region
- Check your network bandwidth and latency
- Verify codec compatibility
- This is usually a Twilio configuration issue
- Check echo cancellation settings in Twilio
- Contact Twilio support if needed
Advanced Configuration
Caller ID & Number Masking
Display your own phone number as the caller ID when making outbound calls:- In Twilio Console, go to Phone Numbers → Verified Caller IDs
- Click Add a new Caller ID (the red plus button)
- Enter the phone number you’d like to show as caller ID
- Complete the verification process:
- Twilio will call or text you with an OTP
- Enter the OTP to verify ownership
- Once verified, configure SIP header manipulation:
- Go to Elastic SIP Trunking → Trunks → [Your Trunk]
- Click on the Termination tab
- Scroll down to SIP Header Manipulation
- Click Create new Policy
- Set the rule to replace the From header with your verified caller ID:
- Save and apply the policy
Geographic Routing
For better call quality, you can set up multiple trunks in different regions:- Create separate SIP trunks for each region (US, EU, APAC)
- Use region-specific Termination URIs
- Import numbers from each trunk separately on Smallest AI
- Assign region-appropriate numbers to your agents
Security Best Practices
- Use credential-based authentication instead of IP whitelisting
- Rotate credentials regularly (every 90 days recommended)
- Set up alerts in Twilio for unusual usage patterns
Cost Considerations
When using Twilio with Smallest AI: Twilio charges:- Monthly number rental fees (varies by country)
- Per-minute outbound call costs (varies by destination)
- Inbound call costs (typically free or very low)
- SIP trunk fees (if applicable to your plan)
- Standard per-minute call rates for AI conversation
- No additional fees for SIP trunk configuration
- No monthly rental fees for imported numbers
Need Help?
If you encounter issues not covered in this guide:- Email Support: support@smallest.ai
- Include in your message:
- Your Twilio phone number
- Your Termination SIP URI
- Description of the issue
- Any error messages you’re seeing
- Join our Community: Discord
- Twilio Support: For Twilio-specific issues, contact Twilio Support
Related Documentation
- SIP Trunking Overview - General SIP trunking concepts
- Phone Numbers - Managing phone numbers on Smallest AI
- Twilio Elastic SIP Trunking Docs - Official Twilio documentation