fix: save call metadata in gathered context for an api trigger outbound call

This commit is contained in:
Sabiha Khan 2026-07-21 15:48:47 +05:30
parent 90c5831984
commit ebacfaad4a
2 changed files with 43 additions and 2 deletions

View file

@ -320,7 +320,7 @@ async def _execute_resolved_target(
# (e.g. Telnyx, Cloudonix); without them the URL contains "None/None" and
# the stream connection fails.
try:
await provider.initiate_call(
result = await provider.initiate_call(
to_number=request.phone_number,
webhook_url=webhook_url,
workflow_run_id=workflow_run.id,
@ -337,6 +337,19 @@ async def _execute_resolved_target(
detail=f"Failed to initiate call: {e}",
)
gathered_context = {
"provider": provider.PROVIDER_NAME,
"triggered_by": "api",
**(result.provider_metadata or {}),
}
if target.identifier_type == "trigger_path":
gathered_context["trigger_uuid"] = target.identifier_value
await db_client.update_workflow_run(
run_id=workflow_run.id,
gathered_context=gathered_context,
)
logger.info(
f"Call initiated successfully for workflow run {workflow_run.id} "
f"via {target.identifier_type}={target.identifier_value}"