zoom support
This commit is contained in:
parent
1c5d4eb7ab
commit
32a1ddca40
4 changed files with 98 additions and 11 deletions
|
|
@ -8,15 +8,16 @@ from vocode.models.agent import (
|
||||||
WebSocketUserImplementedAgentConfig,
|
WebSocketUserImplementedAgentConfig,
|
||||||
)
|
)
|
||||||
from vocode.models.message import BaseMessage
|
from vocode.models.message import BaseMessage
|
||||||
|
from vocode.telephony.zoom_dial_in import ZoomDialIn
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
call = OutboundCall(
|
call = ZoomDialIn(
|
||||||
recipient=CallEntity(
|
recipient=CallEntity(phone_number="<zoom_phone_number>"),
|
||||||
phone_number="+11234567890",
|
|
||||||
),
|
|
||||||
caller=CallEntity(
|
caller=CallEntity(
|
||||||
phone_number="+11234567890",
|
phone_number="<your_phone_number>",
|
||||||
),
|
),
|
||||||
|
zoom_meeting_id="<zoom_meeting_id>",
|
||||||
|
zoom_meeting_password="<zoom_meeting_password>",
|
||||||
agent_config=ChatGPTAgentConfig(
|
agent_config=ChatGPTAgentConfig(
|
||||||
initial_message=BaseMessage(text="the quick fox jumped over the lazy dog "),
|
initial_message=BaseMessage(text="the quick fox jumped over the lazy dog "),
|
||||||
prompt_preamble="respond two sentences at a time",
|
prompt_preamble="respond two sentences at a time",
|
||||||
|
|
@ -29,3 +30,5 @@ if __name__ == "__main__":
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
call.start()
|
call.start()
|
||||||
|
input("Press enter to end the call...")
|
||||||
|
call.end()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,10 @@ class CreateInboundCall(BaseModel):
|
||||||
agent_config: AgentConfig
|
agent_config: AgentConfig
|
||||||
synthesizer_config: Optional[SynthesizerConfig] = None
|
synthesizer_config: Optional[SynthesizerConfig] = None
|
||||||
twilio_sid: str
|
twilio_sid: str
|
||||||
conversation_id: Optional[str] = None
|
|
||||||
|
|
||||||
|
class EndOutboundCall(BaseModel):
|
||||||
|
call_id: str
|
||||||
|
|
||||||
|
|
||||||
class CreateOutboundCall(BaseModel):
|
class CreateOutboundCall(BaseModel):
|
||||||
|
|
@ -25,3 +28,14 @@ class CreateOutboundCall(BaseModel):
|
||||||
synthesizer_config: Optional[SynthesizerConfig] = None
|
synthesizer_config: Optional[SynthesizerConfig] = None
|
||||||
conversation_id: Optional[str] = None
|
conversation_id: Optional[str] = None
|
||||||
# TODO add IVR/etc.
|
# TODO add IVR/etc.
|
||||||
|
|
||||||
|
|
||||||
|
class DialIntoZoomCall(BaseModel):
|
||||||
|
recipient: CallEntity
|
||||||
|
caller: CallEntity
|
||||||
|
zoom_meeting_id: str
|
||||||
|
zoom_meeting_password: Optional[str]
|
||||||
|
transcriber_config: Optional[TranscriberConfig] = None
|
||||||
|
agent_config: AgentConfig
|
||||||
|
synthesizer_config: Optional[SynthesizerConfig] = None
|
||||||
|
conversation_id: Optional[str] = None
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,12 @@ from typing import Optional
|
||||||
from vocode.models.agent import AgentConfig
|
from vocode.models.agent import AgentConfig
|
||||||
from vocode.models.synthesizer import SynthesizerConfig
|
from vocode.models.synthesizer import SynthesizerConfig
|
||||||
from vocode.models.transcriber import TranscriberConfig
|
from vocode.models.transcriber import TranscriberConfig
|
||||||
from ..models.telephony import CallEntity, CreateOutboundCall
|
from ..models.telephony import CallEntity, CreateOutboundCall, EndOutboundCall
|
||||||
import requests
|
import requests
|
||||||
from .. import api_key, BASE_URL
|
from .. import api_key, BASE_URL
|
||||||
|
|
||||||
VOCODE_OUTBOUND_CALL_URL = f"https://{BASE_URL}/create_outbound_call"
|
VOCODE_CREATE_OUTBOUND_CALL_URL = f"https://{BASE_URL}/create_outbound_call"
|
||||||
|
VOCODE_END_OUTBOUND_CALL_URL = f"https://{BASE_URL}/end_outbound_call"
|
||||||
|
|
||||||
|
|
||||||
class OutboundCall:
|
class OutboundCall:
|
||||||
|
|
@ -17,16 +18,18 @@ class OutboundCall:
|
||||||
agent_config: AgentConfig,
|
agent_config: AgentConfig,
|
||||||
transcriber_config: Optional[TranscriberConfig] = None,
|
transcriber_config: Optional[TranscriberConfig] = None,
|
||||||
synthesizer_config: Optional[SynthesizerConfig] = None,
|
synthesizer_config: Optional[SynthesizerConfig] = None,
|
||||||
|
conversation_id: Optional[str] = None,
|
||||||
):
|
):
|
||||||
self.recipient = recipient
|
self.recipient = recipient
|
||||||
self.caller = caller
|
self.caller = caller
|
||||||
self.agent_config = agent_config
|
self.agent_config = agent_config
|
||||||
self.transcriber_config = transcriber_config
|
self.transcriber_config = transcriber_config
|
||||||
self.synthesizer_config = synthesizer_config
|
self.synthesizer_config = synthesizer_config
|
||||||
|
self.conversation_id = conversation_id
|
||||||
|
|
||||||
def start(self):
|
def start(self) -> str:
|
||||||
return requests.post(
|
response = requests.post(
|
||||||
VOCODE_OUTBOUND_CALL_URL,
|
VOCODE_CREATE_OUTBOUND_CALL_URL,
|
||||||
headers={"Authorization": f"Bearer {api_key}"},
|
headers={"Authorization": f"Bearer {api_key}"},
|
||||||
json=CreateOutboundCall(
|
json=CreateOutboundCall(
|
||||||
recipient=self.recipient,
|
recipient=self.recipient,
|
||||||
|
|
@ -34,5 +37,19 @@ class OutboundCall:
|
||||||
agent_config=self.agent_config,
|
agent_config=self.agent_config,
|
||||||
transcriber_config=self.transcriber_config,
|
transcriber_config=self.transcriber_config,
|
||||||
synthesizer_config=self.synthesizer_config,
|
synthesizer_config=self.synthesizer_config,
|
||||||
|
conversation_id=self.conversation_id,
|
||||||
).dict(),
|
).dict(),
|
||||||
)
|
)
|
||||||
|
assert response.ok, response.text
|
||||||
|
data = response.json()
|
||||||
|
self.conversation_id = data["id"]
|
||||||
|
|
||||||
|
def end(self) -> str:
|
||||||
|
response = requests.post(
|
||||||
|
VOCODE_END_OUTBOUND_CALL_URL,
|
||||||
|
headers={"Authorization": f"Bearer {api_key}"},
|
||||||
|
json=EndOutboundCall(
|
||||||
|
call_id=self.conversation_id,
|
||||||
|
).dict(),
|
||||||
|
)
|
||||||
|
assert response.ok, response.text
|
||||||
|
|
|
||||||
53
vocode/telephony/zoom_dial_in.py
Normal file
53
vocode/telephony/zoom_dial_in.py
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
from typing import Optional
|
||||||
|
from vocode.models.agent import AgentConfig
|
||||||
|
from vocode.models.synthesizer import SynthesizerConfig
|
||||||
|
from vocode.models.transcriber import TranscriberConfig
|
||||||
|
from vocode.telephony.outbound_call import OutboundCall
|
||||||
|
from ..models.telephony import CallEntity, DialIntoZoomCall
|
||||||
|
import requests
|
||||||
|
from .. import api_key, BASE_URL
|
||||||
|
|
||||||
|
VOCODE_ZOOM_DIAL_IN_URL = f"https://{BASE_URL}/dial_into_zoom_call"
|
||||||
|
|
||||||
|
|
||||||
|
class ZoomDialIn(OutboundCall):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
recipient: CallEntity,
|
||||||
|
caller: CallEntity,
|
||||||
|
zoom_meeting_id: str,
|
||||||
|
zoom_meeting_password: str,
|
||||||
|
agent_config: AgentConfig,
|
||||||
|
transcriber_config: Optional[TranscriberConfig] = None,
|
||||||
|
synthesizer_config: Optional[SynthesizerConfig] = None,
|
||||||
|
conversation_id: Optional[str] = None,
|
||||||
|
):
|
||||||
|
super().__init__(
|
||||||
|
recipient=recipient,
|
||||||
|
caller=caller,
|
||||||
|
agent_config=agent_config,
|
||||||
|
transcriber_config=transcriber_config,
|
||||||
|
synthesizer_config=synthesizer_config,
|
||||||
|
conversation_id=conversation_id,
|
||||||
|
)
|
||||||
|
self.zoom_meeting_id = zoom_meeting_id
|
||||||
|
self.zoom_meeting_password = zoom_meeting_password
|
||||||
|
|
||||||
|
def start(self) -> str:
|
||||||
|
response = requests.post(
|
||||||
|
VOCODE_ZOOM_DIAL_IN_URL,
|
||||||
|
headers={"Authorization": f"Bearer {api_key}"},
|
||||||
|
json=DialIntoZoomCall(
|
||||||
|
recipient=self.recipient,
|
||||||
|
caller=self.caller,
|
||||||
|
zoom_meeting_id=self.zoom_meeting_id,
|
||||||
|
zoom_meeting_password=self.zoom_meeting_password,
|
||||||
|
agent_config=self.agent_config,
|
||||||
|
transcriber_config=self.transcriber_config,
|
||||||
|
synthesizer_config=self.synthesizer_config,
|
||||||
|
conversation_id=self.conversation_id,
|
||||||
|
).dict(),
|
||||||
|
)
|
||||||
|
assert response.ok, response.text
|
||||||
|
data = response.json()
|
||||||
|
self.conversation_id = data["id"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue