6
6
CHANNELS = 1
7
7
8
8
9
- def create_web_call (api_url , api_key , assistant ):
9
+ def create_web_call (api_url , api_key , payload ):
10
10
url = f"{ api_url } /call/web"
11
11
headers = {
12
12
'Authorization' : 'Bearer ' + api_key ,
13
13
'Content-Type' : 'application/json'
14
14
}
15
- response = requests .post (url , headers = headers , json = assistant )
15
+ response = requests .post (url , headers = headers , json = payload )
16
16
data = response .json ()
17
17
if response .status_code == 201 :
18
18
call_id = data .get ('id' )
@@ -27,15 +27,29 @@ def __init__(self, *, api_key, api_url="https://api.vapi.ai"):
27
27
self .api_key = api_key
28
28
self .api_url = api_url
29
29
30
- def start (self , * , assistant_id = None , assistant = None , assistant_overrides = None ):
30
+ def start (
31
+ self ,
32
+ * ,
33
+ assistant_id = None ,
34
+ assistant = None ,
35
+ assistant_overrides = None ,
36
+ squad_id = None ,
37
+ squad = None ,
38
+ ):
31
39
# Start a new call
32
40
if assistant_id :
33
- assistant = {'assistantId' : assistant_id , 'assistantOverrides' : assistant_overrides }
41
+ payload = {'assistantId' : assistant_id , 'assistantOverrides' : assistant_overrides }
34
42
elif assistant :
35
- assistant = {'assistant' : assistant , 'assistantOverrides' : assistant_overrides }
43
+ payload = {'assistant' : assistant , 'assistantOverrides' : assistant_overrides }
44
+ elif squad_id :
45
+ payload = {'squadId' : squad_id }
46
+ elif squad :
47
+ payload = {'squad' : squad }
48
+ else :
49
+ raise Exception ("Error: No assistant specified." )
36
50
37
51
call_id , web_call_url = create_web_call (
38
- self .api_url , self .api_key , assistant )
52
+ self .api_url , self .api_key , payload )
39
53
40
54
if not web_call_url :
41
55
raise Exception ("Error: Unable to create call." )
0 commit comments