""" 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)