Play a sound file to the callee before the actual call start

Quick question.

When the asterisk PBX is dialing the calle. How can i play a sound file before the actual conversation starts for the calle ?

Was already looking at Dial - Asterisk Documentation

Same question was already asked here, but did not gave us the solution Play audio file in callee

Define “call start”.

The only easy way is with the A option, but that assumes the call start is when the caller is able to start speaking.

You could possibly do something complicated such as:

  1. 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

  2. When the destination answers, play them the sound file (caller still hasn’t
    been answered yet).

  3. 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.

Here is the scenario

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.

That’s the simple case, except that the names make me think this is not a simple inbound call.

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.

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