mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-07 07:55:16 +02:00
feat: add cloudonix amd callback with logs only (#177)
This commit is contained in:
parent
bd07b753cd
commit
628132f29b
2 changed files with 32 additions and 0 deletions
|
|
@ -1209,6 +1209,33 @@ async def handle_cloudonix_status_callback(
|
|||
|
||||
return {"status": "success"}
|
||||
|
||||
@router.post("/cloudonix/amd-callback/{workflow_run_id}")
|
||||
async def handle_cloudonix_amd_callback(
|
||||
workflow_run_id: int,
|
||||
request: Request,
|
||||
):
|
||||
"""Handle Cloudonix-specific Answering Machine Detection(AMD) callbacks.
|
||||
Cloudonix sends AMD updates to the callback URL specified during call initiation.
|
||||
"""
|
||||
set_current_run_id(workflow_run_id)
|
||||
|
||||
content_type = request.headers.get("content-type", "")
|
||||
|
||||
if "application/json" in content_type:
|
||||
callback_data = await request.json()
|
||||
else:
|
||||
form_data = await request.form()
|
||||
callback_data = dict(form_data)
|
||||
|
||||
call_id = callback_data["CallSid"]
|
||||
answered_by = callback_data["AnsweredBy"]
|
||||
|
||||
logger.info(
|
||||
f"[run {workflow_run_id}] Received Cloudonix AMD status callback with answered-by {answered_by} for call ID {call_id}: {json.dumps(callback_data)}"
|
||||
)
|
||||
|
||||
return {"status": answered_by}
|
||||
|
||||
|
||||
@router.post("/vobiz/hangup-callback/workflow/{workflow_id}")
|
||||
async def handle_vobiz_hangup_callback_by_workflow(
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@ class CloudonixProvider(TelephonyProvider):
|
|||
</Response>""",
|
||||
"caller-id": from_number, # Required field
|
||||
}
|
||||
data["machineDetection"] = "DetectMessageEnd"
|
||||
data["asyncAmd"] = True
|
||||
data["asyncAmdStatusCallback"] = f"{backend_endpoint}/api/v1/telephony/cloudonix/amd-callback/{workflow_run_id}"
|
||||
data["asyncAmdStatusCallbackMethod"]= "POST"
|
||||
|
||||
|
||||
# TODO: Cloudonix status callbacks are spammy, so commenting it out. Can send it to
|
||||
# some persistent logging system instead of transcational database.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue