Twilio
Learn using a step-by-step guide on how to integrate Twilio with AI Agents
What is Twilio?
Twilio integration allows you to connect BotPenguin with Twilio's powerful voice and SMS communication platform. It enables data exchange between systems, allowing you to make and receive phone calls, send SMS messages, and automate customer communication workflows seamlessly. With Twilio, you can leverage SIP trunking for reliable voice connectivity and manage your phone numbers and billing all from one platform.
When should you use this?
Use this integration when:
You want to connect BotPenguin with Twilio's voice communication services
You need to enable outbound and inbound calling capabilities for your agents
You are trying to automate voice-based customer interactions and workflows
You need to manage multiple phone numbers across different regions
You want to handle compliance requirements for phone numbers in specific countries
Benefits of Twilio Integration
π Enables seamless voice and SMS communication between BotPenguin and Twilio
β‘ Automates outbound and inbound call workflows with SIP trunking
π― Improves customer engagement through reliable voice connectivity
π Ensures real-time call routing and configuration management
π Reduces communication setup complexity with integrated number management
Expected Outcome
After setting this up:
Your Twilio account will be successfully connected to BotPenguin
Data will flow between BotPenguin β Twilio
You will be able to make and receive calls through your Twilio phone number
Your agents will have access to both inbound and outbound calling capabilities
Tip: Test the integration with sample calls (both inbound and outbound) after setup to ensure everything is working correctly.
π Prerequisites
Before setting up this integration, ensure you have:
An active Twilio account (sign up at https://www.twilio.com/)
Completed the Twilio verification process with your account
Purchased at least one phone number from Twilio
Admin or Owner access to your Twilio account
Billing information added to your Twilio account (payment method on file)
Compliance verification completed for your country (required for phone numbers)
Missing prerequisites may result in failed connections or limited functionality. Compliance requirements vary by countryβensure you have met your region's requirements before purchasing a number.
How to Use Twilio Integration
Phase 1: Set Up Your Twilio Account
Visit the Twilio website at https://www.twilio.com/ and sign up for a free Twilio account.
Complete the Twilio verification process to set up your account with your country information and required documentation.
Once verified, log into the Twilio Console at https://console.twilio.com.

Phase 2: Purchase a Phone Number
From your Twilio Console home page, navigate to "Phone Numbers" in the left sidebar.
Click on "Buy a Number" button to purchase a new phone number.

Filter the available numbers by:
Country: Select the country where you want the number
Capabilities: Select "Voice"

Select the phone number you want to purchase and click "Buy".

Configure the purchased number:
Set a Friendly Name (internal name for your reference)
Review the number configuration
Click "Buy this Number" to complete the purchase
Important: Compliance requirements vary by country. During account setup, your country information and documents will be verified for compliance purposes. If your account is not yet compliant in a specific region, you may need to create a new account or contact Twilio support.
Phase 3: Create an Elastic SIP Trunk
In the Twilio Console, navigate to "Elastic SIP Trunking" β "Manage" β "Trunks".
Click "Create new SIP Trunk" and give it a friendly name (e.g., "BotPenguin Trunk" or "LiveKit Trunk")
Click "Create" to create your new trunk. You will now configure both Origination (inbound) and Termination (outbound) on this single trunk.
Phase 4: Configure Origination (Inbound Calls)
Origination is how Twilio forwards incoming calls to your BotPenguin agent.
Inside your trunk, go to the "Origination" tab.
Click "Add New Origination URI" and enter the following as the SIP URI:
Important: Include the sip: prefix and the ;transport=tcp suffix. Without these, the trunk will not connect properly.
Set the following values:
Priority: 1
Weight: 1
Enabled: Make sure this is checked
Click "Save".
Attach Your Phone Number to the Trunk
Inside your trunk, go to the "Numbers" tab.
Click "Add an Existing Number" and select your Twilio phone number from the dropdown.
Click "Save".
Phase 5: Configure Termination (Outbound Calls)
Termination is how your BotPenguin agent sends outbound calls through Twilio. The values configured here will be used in the installation form.
Inside your trunk, go to the "Termination" tab.
Set a Termination SIP URI. Pick any unique subdomain, for example:
Tip: Replace "yourname" with something unique to your organization. This full URI (without the sip: prefix) is what you will paste into the Termination URI field in BotPenguin.
Click "Save".
Under "Authentication" β "Credential Lists", click the "+" icon to create a new credential list.
Create a Username and a strong Password inside that credential list.
Critical: Write down the username and password now β you will paste both into the BotPenguin installation form. Twilio will not show the password again.
Click "Save" to create the credential list.
Back on the trunk Termination tab, make sure the credential list you just created is attached under "Termination" β "Authentication" β "Credential Lists".
Click "Save" to finalize your Termination configuration.
Phase 6: Fill in the "Install Myself" Form
Now that your Elastic SIP Trunk is configured in Twilio, you'll connect it to BotPenguin using the installation form.
Go to the "Integrations" section in BotPenguin from the left sidebar.
Locate "Twilio" and click "Connect".
Expand the "Install Myself" panel to access the installation form.
Fill in the form fields with the following information:
Country Code
Country code of your Twilio number (e.g., +1, +44)
Select from dropdown before Phone Number
Phone Number
Your Twilio phone number without country code
Twilio β Phone Numbers β Manage β Active Numbers
Termination URI
Your Twilio Termination SIP URI (e.g., yourname.pstn.twilio.com)
Twilio β Elastic SIP Trunking β Trunks β your trunk β Termination
Username
The username from your Credential List
Twilio β Elastic SIP Trunking β Credential Lists
Password
The password from your Credential List
Twilio β Elastic SIP Trunking β Credential Lists
Outbound Transport
TCP
Select from dropdown (default)
Click "Configure" to complete the installation. Installation can take up to 30 seconds.
π‘ Tip: Keep your Twilio console open during this process to reference the correct values from your trunk and credential list configuration.
Phase 8: Test the Twilio Setup
After configuration completes, test both inbound and outbound calls to ensure everything is working correctly.
Inbound Call Test
From any phone, call your Twilio phone number.
Your BotPenguin agent should answer the call.
Success: If your agent answers, inbound calling is working correctly.
Outbound Call Test
In the BotPenguin agent dashboard, trigger an outbound call to your phone number.
Your phone should ring and you should be able to hear the agent speak.
Success: If you receive the call and hear the agent, outbound calling is working correctly.
If Something Fails
Check Twilio's call logs under Monitor β Logs β Calls for error details.
Check BotPenguin call logs for any connection errors
Verify that:
Your Termination SIP URI is correctly formatted (e.g., yourname.pstn.twilio.com)
Your username and password match your credential list exactly
Your phone number is attached to the correct Origination URI
All credentials are correctly entered in the BotPenguin form
π‘ Common Issue: Make sure you entered the Termination URI without the
sip:prefix. The form should receive only the domain (e.g., yourname.pstn.twilio.com)
Best Practices
π‘ Always test the integration with both inbound and outbound test calls before deploying to production.
β οΈ Store your SIP credentials and Auth Token securely and never share them in plain text communications.
π Use clear, descriptive names for your inbound and outbound trunks to avoid confusion during troubleshooting.
π― Monitor Twilio logs regularly to identify and resolve connectivity or configuration issues early.
π Keep your billing information current and monitor your account balance to ensure uninterrupted service.
π Ensure compliance documentation is kept up-to-date, as requirements may change by region.
Troubleshooting
Issue: Calls not connecting - "Connection Failed" error
Solution:
Verify all form fields are entered correctly. Check that your Termination URI is formatted correctly (for example, yourname.pstn.twilio.com) without the sip: prefix. Ensure your username and password match exactly what's in your Elastic SIP Trunk Credential List. Check Twilio logs under Monitor β Logs β Calls for error details.
Issue: Inbound calls not reaching the agent
Solution: In your Twilio Elastic SIP Trunk, verify that the Origination URI is exactly:
FAQ's
What is Elastic SIP Trunking?
Elastic SIP Trunking is Twilio's SIP trunking solution that allows you to connect your applications directly to Twilio's voice infrastructure. It provides both inbound (Origination) and outbound (Termination) call handling through a single trunk configuration.
Why do I need to create both Origination and Termination configurations?
Origination handles how Twilio forwards incoming calls to your BotPenguin agent. Termination handles how your agent sends outbound calls through Twilio. Both must be configured for complete two-way calling functionality.
What is the Origination URI and why is the transport=tcp suffix required?
The Origination URI is the endpoint where Twilio sends incoming calls. The transport=tcp suffix ensures secure, reliable delivery of SIP signaling. Without it, the connection will fail.
Can I change my Termination URI after setup?
Yes, you can modify your Termination URI in the Twilio Elastic SIP Trunking trunk configuration. However, you'll need to update the corresponding value in BotPenguin and reconfigure the integration.
What happens if I forget my SIP credentials password?
If you forget your SIP credentials password, create a new Credential List in Twilio's Elastic SIP Trunking section. Remove the old credentials from the Termination configuration, attach the new Credential List, and update the password in BotPenguin.
Can I use the same Elastic SIP Trunk for multiple phone numbers?
Yes, you can attach multiple phone numbers to the same Elastic SIP Trunk. All numbers will use the same Origination and Termination configurations.
What should I do if inbound calls work but outbound calls don't?
Outbound calls use your Termination configuration. Verify that your Termination URI is correctly formatted (without the sip: prefix), your Credential List is attached to the Termination tab, and your username and password are correct. Check Twilio's Monitor β Logs β Calls for authentication errors.
Is the Origination URI the same for all BotPenguin integrations?
Yes. The Origination URI below is the same for all Twilio Elastic SIP Trunking integrations with BotPenguin:
How long does it take for the configuration to be live after clicking Configure?
Installation can take up to 30 seconds. After this period, your integration should be ready for testing. Test both inbound and outbound calls to verify everything is working.
Where can I find detailed call logs for debugging?
Call logs are available in your Twilio Console under Monitor β Logs β Calls. This shows detailed information about all calls, including any errors or failures. BotPenguin also maintains its own logs for integration issues.
Support
If you still have questions for our team, write to us at support@botpenguin.com. We'll get back to you within 48 hours.
π Completion
π Congratulations, you have successfully set up the Twilio integration! You can now enable your agents to make and receive calls, automate voice workflows, and enhance your customer communication capabilities with reliable voice connectivity through Twilio.
Last updated
Was this helpful?