From 1d0a7cd2d863b13feefe171dea42520c152fc2bd Mon Sep 17 00:00:00 2001 From: Zakir Jiwani Date: Fri, 17 Apr 2026 02:12:57 -0400 Subject: [PATCH] Fix inbound call phone numbers not shown in usage logs (#241) For outbound calls, the caller phone is stored as "phone_number" in initial_context. For inbound calls, it is stored as "caller_number". The usage log extraction only checked "phone_number", so inbound caller numbers were never surfaced. Add a fallback to also check "caller_number" when "phone_number" is absent. Co-authored-by: Claude Sonnet 4.6 --- api/db/organization_usage_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/db/organization_usage_client.py b/api/db/organization_usage_client.py index 582ede9..5968475 100644 --- a/api/db/organization_usage_client.py +++ b/api/db/organization_usage_client.py @@ -316,9 +316,10 @@ class OrganizationUsageClient(BaseDBClient): total_duration_seconds += int(round(call_duration)) # Extract phone number from initial_context + # Outbound calls store it as "phone_number"; inbound calls store it as "caller_number" phone_number = None if run.initial_context: - phone_number = run.initial_context.get("phone_number") + phone_number = run.initial_context.get("phone_number") or run.initial_context.get("caller_number") # Extract disposition from gathered_context disposition = None