How to transfer a call from AudioSocket after condition is met?

Hi everyone,

I’m working on an Asterisk-based solution where I receive a call in the dialplan and forward the RTP stream to a Python server using AudioSocket. Here’s a simplified version of my dialplan:

// Set UUID
Set(__UUID=${uuid});

// Capture and send the RTP stream
AudioSocket(${uuid},10.1.1.107:1121,${CHANNEL(channel)});

// Hang up the call
hangup();

After this, the call media is handled in my Python code connected to the AudioSocket. Within this Python code, I want to check for certain conditions, and if those conditions are met, I need to transfer the ongoing call to another number, for example, 0123456789.

I tried returning something back to the dialplan to make the transfer, but I could not get it working.

Could someone please explain how to properly handle this type of transfer?

  • Should I reinject control back into the dialplan somehow?
  • Or should I issue an AMI/ARI command from the Python side to redirect the channel?
  • What is the best practice for this scenario?

Thanks for any guidance!