Asterisk plays file before phone picked up


when placing an outgoing call (by a call file), how do you make asterisk wait for the phone to be picked up before playing a sound file?

The call file looks like this:

Channel: SIP/number@provider
MaxRetries: 3
RetryTime: 90
WaitTime: 90
Context: 10000
Extension: myext
Priority: 1

Asterisk correctly places the call and jumps to

exten => myext,1,Answer()
;I think, I should check here whether phone was picked up.
exten => myext,n,Playback(mymessage)

When I pick up the phone, * is half through the message because it starts replaying it right away and doesn’t wait for the user to pick the phone up.

Thanks for your help,I really appreciate it.


You could try this:

exten => myext,1,Answer()
exten => myext,n,Wait(2)
exten => myext,n,Playback(mymessage)

That makes * wait 2 secs before starting the replay, won’t do any good (tried it anyway and it doesn’t help).

But I came across some documentation mentioning that it is default * call file behavior to first wait for the channel to be answered, THEN jump to the dial plan.
Check it out:


My asterisk seems to jump to the dial plan right away though, any ideas?

May be this will lead to a clue:
I open a SIP channel with the Call File and the SIP channel is forwarded to a land line by a gateway provider. Would it be possible that what causes the problem is this:
The gateway provider answers the SIP channel to be able to forward it to a land line. For asterisk, the channel is instantly “answered” by my external provider to process the forward even though the land line the call is routed to has not been picked up yet.

What do you think?

It’s certainly possible.

What about putting a Wait() before the Answer(), or extending the Wait() afterward? If * considers the call answered, as far as I know it’s the only way to delay playing the message.

That won’t help either. You would have to guess the time before the phone is picked up.

You may be able to use waitforsilence to wait for a specified length of silence prior to playing the message. The silence threshold would need to be longer than the time between rings.

You have to check for the status. This is a copy and past of a working configuration. I did some translations of the labels because they were in Dutch. I hope I didn’t make any typos

[meetmecall_outbound] ;
exten => s,1,Answer()
exten => s,n(gotoif),Gotoif($[ “${DIALSTATUS}” : “NOANSWER”]?wait:continue)
exten => s,n(wait),Wait(1)
exten => s,n,Goto(gotoif)

exten => s,n(continue),Playback(silence/1)
exten => s,n,Playback(meetmecall/mmc_enter_room)

This should be it.