iajitpanday commited on
Commit
c8c2acf
·
verified ·
1 Parent(s): 182497c

Create twilio_setup.py

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