A proxy that redirects Twilio SDK calls to Telnyx's API
Project description
Twilnyx
A proxy that redirects Twilio SDK calls to use Telnyx's API. Keep using your existing Twilio code and webhook server - just add two lines to use Telnyx instead!
Installation
pip install twilnyx
Usage
Your existing Twilio code:
from twilio.rest import Client
client = Client('TWILIO_ACCOUNT_SID', 'TWILIO_AUTH_TOKEN')
call = client.calls.create(
url='https://your-server.com/voice', # Your webhook server
to='+1234567890',
from_='+1987654321'
)
To use Telnyx instead, just add:
# Add these two lines at the start of your code
import twilnyx
twilnyx.use_telnyx(
api_key='YOUR_TELNYX_API_KEY',
voice_profile_id='YOUR_VOICE_PROFILE_ID' # From Telnyx Portal > Voice > API Profiles
)
# Then use your existing Twilio code as-is!
from twilio.rest import Client
...
How It Works
-
Basic Flow:
Your Code -> Twilio SDK -> Twilnyx Proxy -> Telnyx API | v Parameter Mapping Add Voice Profile Convert Response -
Complete Flow:
+-------------+ +------------+ +-------------+ +-----------+ | Your Code | |Twilio SDK | |Twilnyx Proxy| |Telnyx API | | |--->| |--->| |--->| | +-------------+ +------------+ +-------------+ +-----------+ | v +---------------+ | Map Params | | Add Profile | | Map Response | +---------------+ -
Webhook Flow:
+-------------+ +------------+ +------------+ | Your App | |Telnyx API | |Your Server | |client.calls | | | | /voice | | |--->| |--->| | | | | | | | | | | |<---| TwiML | +-------------+ +------------+ +------------+ -
Parameter Mapping:
# Twilio format { 'To': '+1234567890', 'From': '+1987654321', 'Url': 'https://your-server.com/voice' } # Converted to Telnyx format { 'to': '+1234567890', 'from': '+1987654321', 'webhook_url': 'https://your-server.com/voice', 'voice_profile_id': 'your_profile_id' # Added automatically }
-
Response Conversion:
# Telnyx response { 'call_control_id': 'xyz', 'state': 'ringing' } # Converted to Twilio format { 'sid': 'xyz', 'status': 'ringing' }
Required Setup
-
Telnyx Voice Profile (Required):
- Create in Telnyx Portal > Voice > API Profiles
- Used for outbound calling configuration
- Pass the ID to
use_telnyx()
-
Your Webhook Server:
- Keep using your existing webhook server
- It should return TwiML just like with Twilio
- No changes needed to your webhooks
Features
- Uses your existing Twilio code
- Uses your existing webhook server
- No code changes needed
- Automatic parameter mapping
- Proper response conversion
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file twilnyx-0.1.0.tar.gz.
File metadata
- Download URL: twilnyx-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2ff5997aedf1a5a863cbdeffa3cf518143b6060cac32e20bf7433e3ab7221df
|
|
| MD5 |
728fd12656b31e2733c190fbc960a483
|
|
| BLAKE2b-256 |
10e65f81edff1b858e0fc8d188a641cf7b1e52d9cff75d0f362f858c1d553abb
|
File details
Details for the file twilnyx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: twilnyx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0cf9ea9c45edc63d67c194871b765368353f4332e8b59e4df7eed068827205b
|
|
| MD5 |
4a271c4f5b65fa8f42694b0a2453730b
|
|
| BLAKE2b-256 |
b8b326ad94bad3ca20387b5f01564fdfa8609d59dd94825607afda04762aece9
|