Skip to content

Commit

Permalink
onboard outbound call
Browse files Browse the repository at this point in the history
  • Loading branch information
ajar98 committed Jul 11, 2024
1 parent ad6e939 commit 09ad0be
Showing 1 changed file with 5 additions and 39 deletions.
44 changes: 5 additions & 39 deletions vocode/streaming/telephony/conversation/outbound_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

from loguru import logger

from vocode.streaming.models.agent import AgentConfig
from vocode.streaming.models.synthesizer import SynthesizerConfig
from vocode.streaming.models.pipeline import PipelineConfig
from vocode.streaming.models.telephony import (
TelephonyConfig,
TwilioCallConfig,
TwilioConfig,
VonageCallConfig,
VonageConfig,
)
from vocode.streaming.models.transcriber import TranscriberConfig
from vocode.streaming.telephony.client.abstract_telephony_client import AbstractTelephonyClient
from vocode.streaming.telephony.client.twilio_client import TwilioClient
from vocode.streaming.telephony.client.vonage_client import VonageClient
Expand All @@ -26,11 +24,9 @@ def __init__(
to_phone: str,
from_phone: str,
config_manager: BaseConfigManager,
agent_config: AgentConfig,
pipeline_config: PipelineConfig,
telephony_config: TelephonyConfig,
telephony_params: Optional[Dict[str, str]] = None,
transcriber_config: Optional[TranscriberConfig] = None,
synthesizer_config: Optional[SynthesizerConfig] = None,
conversation_id: Optional[str] = None,
sentry_tags: Dict[str, str] = {},
digits: Optional[
Expand All @@ -41,13 +37,11 @@ def __init__(
self.to_phone = to_phone
self.from_phone = from_phone
self.config_manager = config_manager
self.agent_config = agent_config
self.pipeline_config = pipeline_config
self.conversation_id = conversation_id or create_conversation_id()
self.telephony_config = telephony_config
self.telephony_params = telephony_params or {}
self.telephony_client = self.create_telephony_client()
self.transcriber_config = self.create_transcriber_config(transcriber_config)
self.synthesizer_config = self.create_synthesizer_config(synthesizer_config)
self.sentry_tags = sentry_tags
self.digits = digits

Expand All @@ -57,30 +51,6 @@ def create_telephony_client(self) -> AbstractTelephonyClient:
elif isinstance(self.telephony_config, VonageConfig):
return VonageClient(base_url=self.base_url, maybe_vonage_config=self.telephony_config)

def create_transcriber_config(
self, transcriber_config_override: Optional[TranscriberConfig]
) -> TranscriberConfig:
if transcriber_config_override is not None:
return transcriber_config_override
if isinstance(self.telephony_config, TwilioConfig):
return TwilioCallConfig.default_transcriber_config()
elif isinstance(self.telephony_config, VonageConfig):
return VonageCallConfig.default_transcriber_config()
else:
raise ValueError("No telephony config provided")

def create_synthesizer_config(
self, synthesizer_config_override: Optional[SynthesizerConfig]
) -> SynthesizerConfig:
if synthesizer_config_override is not None:
return synthesizer_config_override
if isinstance(self.telephony_config, TwilioConfig):
return TwilioCallConfig.default_synthesizer_config()
elif isinstance(self.telephony_config, VonageConfig):
return VonageCallConfig.default_synthesizer_config()
else:
raise ValueError("No telephony config provided")

async def start(self):
logger.debug("Starting outbound call")
self.telephony_id = await self.telephony_client.create_call(
Expand All @@ -93,9 +63,7 @@ async def start(self):
)
if isinstance(self.telephony_client, TwilioClient):
call_config = TwilioCallConfig(
transcriber_config=self.transcriber_config,
agent_config=self.agent_config,
synthesizer_config=self.synthesizer_config,
pipeline_config=self.pipeline_config,
twilio_config=self.telephony_client.twilio_config,
twilio_sid=self.telephony_id,
from_phone=self.from_phone,
Expand All @@ -106,9 +74,7 @@ async def start(self):
)
elif isinstance(self.telephony_client, VonageClient):
call_config = VonageCallConfig(
transcriber_config=self.transcriber_config,
agent_config=self.agent_config,
synthesizer_config=self.synthesizer_config,
pipeline_config=self.pipeline_config,
vonage_config=self.telephony_client.vonage_config,
vonage_uuid=self.telephony_id,
from_phone=self.from_phone,
Expand Down

0 comments on commit 09ad0be

Please sign in to comment.