feat: add default telephony variables

This commit is contained in:
Abhishek Kumar 2026-04-02 14:48:13 +05:30
parent 96c90376c3
commit e7adbc7bad
10 changed files with 38 additions and 4 deletions

View file

@ -187,6 +187,7 @@ async def initiate_call(
call_type=CallType.OUTBOUND,
initial_context={
"phone_number": phone_number,
"called_number": phone_number,
"provider": provider.PROVIDER_NAME,
},
)
@ -220,13 +221,22 @@ async def initiate_call(
**keywords,
)
# Store provider type and any provider-specific metadata in workflow run context
# Store provider metadata and caller_number in workflow run context
gathered_context = {
"provider": provider.PROVIDER_NAME,
**(result.provider_metadata or {}),
}
# Merge caller_number into initial_context now that we know which number was used
updated_initial_context = {
**(workflow_run.initial_context or {}),
"called_number": phone_number,
}
if result.caller_number:
updated_initial_context["caller_number"] = result.caller_number
await db_client.update_workflow_run(
run_id=workflow_run_id, gathered_context=gathered_context
run_id=workflow_run_id,
gathered_context=gathered_context,
initial_context=updated_initial_context,
)
return {"message": f"Call initiated successfully with run name {workflow_run_name}"}

View file

@ -205,6 +205,8 @@ class CampaignCallDispatcher:
"campaign_id": campaign.id,
"provider": provider.PROVIDER_NAME,
"source_uuid": queued_run.source_uuid,
"caller_number": from_number,
"called_number": phone_number,
}
logger.info(f"Final initial_context: {initial_context}")

View file

@ -18,6 +18,7 @@ class CallInitiationResult:
call_id: str # Provider's call identifier (SID for Twilio, UUID for Vonage)
status: str # Initial status (e.g., "queued", "initiated", "started")
caller_number: Optional[str] = None # Caller ID used for the outbound call
provider_metadata: Dict[str, Any] = field(
default_factory=dict
) # Data that needs to be persisted

View file

@ -143,6 +143,7 @@ class ARIProvider(TelephonyProvider):
return CallInitiationResult(
call_id=channel_id,
status=response_data.get("state", "created"),
caller_number=from_number,
provider_metadata={
"call_id": channel_id,
"channel_name": response_data.get("name", ""),

View file

@ -189,6 +189,7 @@ class CloudonixProvider(TelephonyProvider):
return CallInitiationResult(
call_id=session_token,
status="initiated",
caller_number=from_number,
provider_metadata={
"call_id": session_token,
"domain_id": domain_id,

View file

@ -124,6 +124,7 @@ class TelnyxProvider(TelephonyProvider):
return CallInitiationResult(
call_id=call_control_id,
status="initiated",
caller_number=from_number,
provider_metadata={
"call_control_id": call_control_id,
"call_leg_id": call_leg_id,

View file

@ -111,6 +111,7 @@ class TwilioProvider(TelephonyProvider):
return CallInitiationResult(
call_id=response_data["sid"],
status=response_data.get("status", "queued"),
caller_number=from_number,
provider_metadata={"call_id": response_data["sid"]},
raw_response=response_data,
)

View file

@ -150,6 +150,7 @@ class VobizProvider(TelephonyProvider):
return CallInitiationResult(
call_id=call_id,
status="queued", # Vobiz returns "message": "call fired"
caller_number=from_number,
provider_metadata={"call_id": call_id},
raw_response=response_data,
)

View file

@ -137,6 +137,7 @@ class VonageProvider(TelephonyProvider):
return CallInitiationResult(
call_id=response_data["uuid"],
status=response_data.get("status", "started"),
caller_number=from_number,
provider_metadata={
"call_uuid": response_data["uuid"]
}, # Vonage needs UUID persisted for WebSocket