Spaces:
Sleeping
Sleeping
File size: 1,884 Bytes
c8c2acf daac47b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
"""
Script to setup Twilio phone number for the call assistant.
"""
import os
from twilio.rest import Client
import argparse
# Twilio credentials
TWILIO_ACCOUNT_SID = "ACacb8e8cc6de0f7d6c6b9c9f252a38c67"
TWILIO_AUTH_TOKEN = "1b2826409367e9799262553538489e54"
TWILIO_PHONE_NUMBER = "+19704064410"
def setup_twilio(webhook_url):
"""
Configure the Twilio phone number with the correct webhook URLs
Args:
webhook_url: Base URL for the webhook (e.g., "https://your-domain.com")
"""
try:
# Initialize Twilio client
client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
# Update the phone number configuration
phone_number = client.incoming_phone_numbers.list(
phone_number=TWILIO_PHONE_NUMBER
)
if not phone_number:
print(f"Phone number {TWILIO_PHONE_NUMBER} not found in your Twilio account.")
return False
# Update the first matching phone number
phone_number[0].update(
voice_url=f"{webhook_url}/answer",
voice_method="POST",
status_callback=f"{webhook_url}/call_status",
status_callback_method="POST"
)
print(f"Successfully updated Twilio phone number {TWILIO_PHONE_NUMBER}")
print(f"Voice URL: {webhook_url}/answer")
print(f"Status Callback URL: {webhook_url}/call_status")
return True
except Exception as e:
print(f"Error setting up Twilio: {e}")
return False
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Setup Twilio for AI Call Assistant")
parser.add_argument(
"--url",
required=True,
help="Base URL for the webhook (e.g., 'https://your-app.ngrok.io')"
)
args = parser.parse_args()
setup_twilio(args.url) |