Playing a sound file (sln) in an ongoing call to caller and callee using Asterisk ARI

The backstory
The caller is using a wallet with tokens. For each conversation a specific amount of tokens is deducted from the wallet. When the wallet reaches 0 tokens the application tells asterisk to end the call by removing the channel aka hangup from the caller side running and working:

shell_exec('curl -X DELETE -u asterisk:asterisk --silent

An extra item that needs to be implemented is notification (prompt) that tells the caller and the callee the ongoing conversation is about to end. Trying to achive this by checking in what contextthe dialplan is. Getting the context with:


shell_exec('curl -u asterisk:asterisk --silent')


  "id": "1711504264.74",
  "name": "PJSIP/twilio-0000002a",
  "state": "Up",
  "protocol_id": "2126eade59ddd0209db6d63d7726ff15@",
  "caller": {
    "name": "",
    "number": "+xxx"
  "connected": {
    "name": "",
    "number": "1"
  "accountcode": "",
  "dialplan": {
    "context": "ctbVariableOutboundCallStartSuccess",
    "exten": "1",
    "priority": 12,
    "app_name": "Dial",
    "app_data": "PJSIP/+xxx@twilio,30,b(ctbVariableOutboundCallStartHeaders^addheader^1)"
  "creationtime": "2024-03-27T01:51:04.511+0000",
  "language": "en"

So far this is working. Now the tricky part where i get stuck, playing the sound file to both caller and callee.


shell_exec('curl -X POST -u asterisk:asterisk --silent'


{"message":"Channel not in Stasis application"}

How do set the channels from both caller and callee into this stasis. Which looks to me is the reason why the audio file is not played while using the Asterisk ARI. This script is running in PHP.

Edit1: Did some research and it looks like i need to connect to the Asterisk ARI using a websocket connection and than send the play request ?

Edit2: A second option could be an extra context in the dialplan using playback. After the playback the conversation can continue as normal? This context is triggered by what Asterisk ARI endpoint ?