You could possibly do something complicated such as:
Get the incoming invite from the caller, and not answer it, but cause an
Originate() to start a new call (do not use Dial()) to the requested
destination.
When the destination answers, play them the sound file (caller still hasn’t
been answered yet).
Once the sound file has been played, answer the caller and bridge them to
the channel of the callee.
For that definition of call start, you the default is not to answer the caller until everything has been run on the callee, so you don’t need any of that complexity.
[ctbOutboundCallStartSuccess]
exten => 1,1,Verbose(Outbound call start success)
same => n,Set(ctbMonitor=${SHELL(echo '${ctbJsonResult}' | jq '.data.callRecording' | tr -d '\n"')})
same => n,Verbose(Callrecording: ${ctbMonitor})
same => n,ExecIf($[${ctbMonitor}=1]?MixMonitor(${ctbCodexLocation}${ctbSessionId}.wav))
same => n,Set(CALLERID(num)=+${ctbOutboundDialedNumber})
same => n,Dial(PJSIP/+${ctbEmployeeOutboundNumber}@${ctbSipProviderEndpoint}&PJSIP/${ctbEndPointEndpoint},${ctbDialTimeOut},b(ctbOutboundCallStartHeaders^addheader^1))
same => n,Verbose(Call result: ${DIALSTATUS})
The call start is defined as “when the calle picks up to answer the outoigng call from PBX to callee” Before the calle starts the conversation i want to play an audio file which is played for the callee, but not the caller. After playback is finished, continue as usual.
Its a regular call from one caller to one callee. The dialplan uses an external API to get all sorts information before setting up a call. The external API has a wallet system attached to asterisk. Asterisk wil get the logic from the external API to make calls
Some phones support passing url to audio file that is used as ring.
Some phones are able to answer with SIP/183, starting early media. I’m not sure about audio here though as I’ve used it mostly for video preview from doorphones before answering.
The call has been answered. This is a trivial case of playing an announcement to the called party. Either the OP has failed to understand this, or has given a wrong description.