Which channel need to send play request while using Asterisk ARI

I have a simple project which I’m using ARI.

I did the following steps:

  • Snoop Channel
  • Create External Media channel
  • Create Bridge
  • Adding Snoop Channel and External Media Channel to Bridge.

All is ok, I’m receiving RTP stream on my end by External Media channel.

This integration is for OpenAI Realtime api.

2025-03-18T08:53:46,122 INFO     [ari-example.py:57] Processing new channel: 1742280823.203
2025-03-18T08:53:46,123 DEBUG    [connectionpool.py:243] Starting new HTTP connection (1): 127.0.0.1:8088
2025-03-18T08:53:46,131 DEBUG    [connectionpool.py:546] http://127.0.0.1:8088 "POST /ari/channels/1742280823.203/answer HTTP/11" 204 0
2025-03-18T08:53:46,131 INFO     [ari-example.py:134] Answered call on channel: 1742280823.203
2025-03-18T08:53:46,132 INFO     [ari-example.py:102] Opening external media with data: {'app': 'hello-world', 'external_host': '127.0.0.1:9000', 'format': 'ulaw'}
2025-03-18T08:53:46,132 DEBUG    [connectionpool.py:243] Starting new HTTP connection (1): 127.0.0.1:8088
2025-03-18T08:53:46,134 DEBUG    [connectionpool.py:546] http://127.0.0.1:8088 "POST /ari/channels/externalMedia HTTP/11" 200 572
2025-03-18T08:53:46,135 INFO     [ari-example.py:107] Started external media: {'id': '1742280826.204', 'name': 'UnicastRTP/127.0.0.1:9000-0x7fb92408bc60', 'state': 'Down', 'protocol_id': '', 'caller': {'name': '', 'number': ''}, 'connected': {'name': '', 'number': ''}, 'accountcode': '', 'dialplan': {'context': 'default', 'exten': 's', 'priority': 1, 'app_name': 'AppDial2', 'app_data': '(Outgoing Line)'}, 'creationtime': '2025-03-18T08:53:46.133+0200', 'language': 'en', 'channelvars': {'UNICASTRTP_LOCAL_PORT': '15934', 'UNICASTRTP_LOCAL_ADDRESS': '127.0.0.1'}}
2025-03-18T08:53:46,136 DEBUG    [connectionpool.py:243] Starting new HTTP connection (1): 127.0.0.1:8088
2025-03-18T08:53:46,152 DEBUG    [connectionpool.py:546] http://127.0.0.1:8088 "POST /ari/channels/1742280823.203/snoop HTTP/11" 200 430
2025-03-18T08:53:46,152 INFO     [ari-example.py:123] Snoop channel created: {'id': '1742280826.205', 'name': 'Snoop/1742280823.203-00000025', 'state': 'Up', 'protocol_id': '', 'caller': {'name': '', 'number': ''}, 'connected': {'name': '', 'number': ''}, 'accountcode': '', 'dialplan': {'context': 'default', 'exten': 's', 'priority': 1, 'app_name': '', 'app_data': ''}, 'creationtime': '2025-03-18T08:53:46.151+0200', 'language': 'en'}
2025-03-18T08:53:46,153 DEBUG    [connectionpool.py:243] Starting new HTTP connection (1): 127.0.0.1:8088
2025-03-18T08:53:46,153 DEBUG    [connectionpool.py:546] http://127.0.0.1:8088 "POST /ari/bridges HTTP/11" 200 269
2025-03-18T08:53:46,154 INFO     [ari-example.py:145] Created bridge: {'id': 'cbbb163d-9486-4151-ae08-b27a7c4c1e6d', 'technology': 'simple_bridge', 'bridge_type': 'mixing', 'bridge_class': 'stasis', 'creator': 'Stasis', 'name': '', 'channels': [], 'creationtime': '2025-03-18T08:53:46.153+0200', 'video_mode': 'talker'}
2025-03-18T08:53:46,154 DEBUG    [connectionpool.py:243] Starting new HTTP connection (1): 127.0.0.1:8088
2025-03-18T08:53:46,172 DEBUG    [connectionpool.py:546] http://127.0.0.1:8088 "POST /ari/bridges/cbbb163d-9486-4151-ae08-b27a7c4c1e6d/addChannel HTTP/11" 204 0
2025-03-18T08:53:46,172 INFO     [ari-example.py:157] Added channel 1742280826.205 to bridge cbbb163d-9486-4151-ae08-b27a7c4c1e6d
2025-03-18T08:53:46,173 DEBUG    [connectionpool.py:243] Starting new HTTP connection (1): 127.0.0.1:8088
2025-03-18T08:53:46,335 DEBUG    [connectionpool.py:546] http://127.0.0.1:8088 "POST /ari/bridges/cbbb163d-9486-4151-ae08-b27a7c4c1e6d/addChannel HTTP/11" 204 0
2025-03-18T08:53:46,335 INFO     [ari-example.py:157] Added channel 1742280826.204 to bridge cbbb163d-9486-4151-ae08-b27a7c4c1e6d
2025-03-18T08:53:46,338 INFO     [ari-example.py:51] Ignoring already processed or snoop channel: 1742280826.204

Everything is ok until I’m sending OpenAI Audio chunks to Asterisk.

  1. I have tried to send audio chunks back to snoop channel with below request:
    curl -XPOST 127.0.0.1:8088/ari/channels/1742280826.205/play?media=sound:/home/sabuhigr/demo-congrats -u asterisk:asterisk

I saw Asterisk console says its playing but doesn’t hear anything.

  1. I have sended to External Media channel, also same situation, I heard nothing.

  2. I have sended to Bridge, also same situation.

  3. Only I can hear OpenAI audio while I’m sending it to the main channel.

But now the issue is, External Media channel again sends same audio to RTP and OpenAI Realtime just talking with itself.
But it shouldn’t send that audio to back OpenAI Realtime by External Channel RTP stream.

I have not so much knowledge here, maybe you can give me suggestion.
Thanks in advance.

Why not stream it back as RTP via the external media channel?

I have actually tried,
on Asterisk console I see that Asterisk receive RTP Stream back (Just did echo, sending back incoming packages by External channel) but I didn’t hear anything.

Apart from that, I have choosed requests to /play because I see that have a good methods that I can control playbacks. (stop playback, control it like - pause, unpause, restart)

As an example, I want to interrupt bot when caller talks, for that I can send delete request to /playback endpoint to stop it, but I don’t know if we have chance for that on RTP or not.

If you stopped sending RTP then it wouldn’t send… RTP…

Anyway.

Have you done basic verification of media flow without ARI/OpenAI? That is: Sent the call to something like Answer and Playback in the dialplan and confirmed audio flows?

Sure, I will try RTP also interesting for me, as I said there is also issue it doesn’t play anthing however package comes, will check later.

Sure everything is fine on dialplan side I suppose:

[voicebot-test-6]
exten => s,1,Answer
exten => s,n,Stasis(hello-world)
exten => s,n,Hangup

I’m not using Playback on dialplan.

I understand you’re not using Playback, but what I’m asking is that you try that. It verifies that media flows from Asterisk to your endpoint in an easy way and narrows it down. If you can’t hear a playback from the dialplan, then your issue has nothing to do with ARI and is more likely elsewhere.

I have no any problem to hear something.Just there chunks that I sending to play, RTP again sending audios.RTP shouldn’t send audio that I sended to /play endpoint I suppose, it should send only caller voice, am I wrong ?

  • I’m already wrote it incoming RTP stream data to file and listened it (as ulaw), everything is well.
  • RTP stream is carrying correct packages to my RTP receiver and OpenAI understand my data very well.
  • I’m trying to play audio chunks that OpenAI sended me, trying to send request to /channels/{my main channel}/play?media=sound:/my/file(.wav)
  • I’m hear that audio chunks on Asterisk side very well.But I suppose External Media channel again streams that to RTP, and it agains going to OpenAI. Bot talking with itself.

Thats all you asked is ok on my end.

What parameters did you pass when creating the Snoop channel?

1 Like

You directly pointed the issue!
Thanks a lot for your time and idea.

=== Before ===
data = {
“app”: $APP_NAME,
“spy”: “both”
}

===After change both → in, all is well===
data = {
“app”: APP_NAME,
“spy”: “in”
}

I will check it RTP streaming back also, ofc speed will better on RTP, also I can get rid of DELETE playbacks that sits on queue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.