chore: return formatted transcript url

- Return formatted transcript and recording URL
- Harden campaign dispatcher logic
This commit is contained in:
Abhishek Kumar 2026-05-26 13:24:12 +05:30
parent 0716582aa7
commit 7810923bca
30 changed files with 525 additions and 136 deletions

View file

@ -13,6 +13,7 @@ from api.db.models import UserModel
from api.services.auth.depends import get_user
from api.services.mps_service_key_client import mps_service_key_client
from api.services.reports import generate_usage_runs_report_csv
from api.utils.artifacts import artifact_url
router = APIRouter(prefix="/organizations")
@ -49,6 +50,7 @@ class WorkflowRunUsageResponse(BaseModel):
call_duration_seconds: int
recording_url: Optional[str] = None
transcript_url: Optional[str] = None
public_access_token: Optional[str] = None
phone_number: Optional[str] = Field(
default=None,
deprecated=True,
@ -223,6 +225,15 @@ async def get_usage_history(
total_pages = (total_count + limit - 1) // limit
for run in runs:
public_access_token = run.get("public_access_token")
run["transcript_url"] = artifact_url(
public_access_token, "transcript", fallback=run.get("transcript_url")
)
run["recording_url"] = artifact_url(
public_access_token, "recording", fallback=run.get("recording_url")
)
return {
"runs": runs,
"total_dograh_tokens": total_tokens,

View file

@ -41,6 +41,7 @@ from api.services.workflow.trigger_paths import (
validate_trigger_paths,
)
from api.services.workflow.workflow_graph import WorkflowGraph
from api.utils.artifacts import artifact_url
router = APIRouter(prefix="/workflow")
@ -1113,14 +1114,24 @@ async def get_workflow_run(
)
if not run:
raise HTTPException(status_code=404, detail="Workflow run not found")
public_access_token = run.public_access_token
if (run.transcript_url or run.recording_url) and not public_access_token:
public_access_token = await db_client.ensure_public_access_token(run.id)
return {
"id": run.id,
"workflow_id": run.workflow_id,
"name": run.name,
"mode": run.mode,
"is_completed": run.is_completed,
"transcript_url": run.transcript_url,
"recording_url": run.recording_url,
"transcript_url": artifact_url(
public_access_token, "transcript", fallback=run.transcript_url
),
"recording_url": artifact_url(
public_access_token, "recording", fallback=run.recording_url
),
"public_access_token": public_access_token,
"cost_info": {
"dograh_token_usage": (
run.cost_info.get("dograh_token_usage")