Skip to content

Commit b00183e

Browse files
authored
Support squads in start (#8)
1 parent 1ab8345 commit b00183e

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

vapi_python/vapi_python.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
CHANNELS = 1
77

88

9-
def create_web_call(api_url, api_key, assistant):
9+
def create_web_call(api_url, api_key, payload):
1010
url = f"{api_url}/call/web"
1111
headers = {
1212
'Authorization': 'Bearer ' + api_key,
1313
'Content-Type': 'application/json'
1414
}
15-
response = requests.post(url, headers=headers, json=assistant)
15+
response = requests.post(url, headers=headers, json=payload)
1616
data = response.json()
1717
if response.status_code == 201:
1818
call_id = data.get('id')
@@ -27,15 +27,29 @@ def __init__(self, *, api_key, api_url="https://api.vapi.ai"):
2727
self.api_key = api_key
2828
self.api_url = api_url
2929

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+
):
3139
# Start a new call
3240
if assistant_id:
33-
assistant = {'assistantId': assistant_id, 'assistantOverrides': assistant_overrides}
41+
payload = {'assistantId': assistant_id, 'assistantOverrides': assistant_overrides}
3442
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.")
3650

3751
call_id, web_call_url = create_web_call(
38-
self.api_url, self.api_key, assistant)
52+
self.api_url, self.api_key, payload)
3953

4054
if not web_call_url:
4155
raise Exception("Error: Unable to create call.")

0 commit comments

Comments
 (0)