Add support for Cloudonix parameters in WebSocket start event (#549)

* Add support for Cloudonix parameters in WebSocket start event

* fix(cloudonix): remove custom parameter logging

---------

Co-authored-by: Nir Simionovich <nirs@cloudonix.com>
Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
This commit is contained in:
Nir Simionovich 2026-07-17 16:26:44 +03:00 committed by GitHub
parent c0f1c2b238
commit f69ab294af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -627,17 +627,32 @@ class CloudonixProvider(TelephonyProvider):
return
start_context = start.get("context")
custom_parameters = start.get("customParameters")
builtin_context = {
"caller_number": start.get("from"),
"called_number": start.get("to"),
"direction": (
"outbound" if start_context == "outbound-api" else "inbound"
),
"cloudonix_context": start_context,
}
await db_client.update_workflow_run(
run_id=workflow_run_id,
initial_context={
# Flatten customParameters, but never let them overwrite a
# built-in key even when the built-in's value is None.
key: value
for key, value in {
"caller_number": start.get("from"),
"called_number": start.get("to"),
"direction": (
"outbound" if start_context == "outbound-api" else "inbound"
),
"cloudonix_context": start_context,
**{
k: v
for k, v in (
custom_parameters
if isinstance(custom_parameters, dict)
else {}
).items()
if k not in builtin_context
},
**builtin_context,
}.items()
if value is not None
},
@ -1059,7 +1074,7 @@ class CloudonixProvider(TelephonyProvider):
"<Response>"
"<Say>You have answered a transfer call. Connecting you now.</Say>"
"<Dial>"
f'<Conference endConferenceOnExit="true" statusCallback="{callback_url}" statusCallbackEvent="join" holdMusic="false" beep="false">{conference_name}</Conference>'
f'<Conference endConferenceOnExit="true" statusCallback="{callback_url}" statusCallbackEvent="join" holdMusic="false">{conference_name}</Conference>'
"</Dial>"
"</Response>"
)
@ -1096,7 +1111,9 @@ class CloudonixProvider(TelephonyProvider):
from_number = random.choice(self.from_numbers)
backend_endpoint, _ = await get_backend_endpoints()
callback_url = f"{backend_endpoint}/api/v1/telephony/cloudonix/transfer-result/{transfer_id}"
callback_url = (
f"{backend_endpoint}/api/v1/telephony/cloudonix/transfer-result/{transfer_id}"
)
endpoint = f"{self.base_url}/calls/{self.domain_id}/application"
data: Dict[str, Any] = {
@ -1109,7 +1126,9 @@ class CloudonixProvider(TelephonyProvider):
data.update(kwargs)
headers = self._get_auth_headers()
masked_destination = f"***{destination[-4:]}" if len(destination) > 4 else "***"
masked_destination = (
f"***{destination[-4:]}" if len(destination) > 4 else "***"
)
logger.info(
f"[Cloudonix Transfer] Dialing {masked_destination} into conference "
f"{conference_name} (transfer_id={transfer_id})"