How to recall in originate command with dialplan?

Hello everyone!

I try to realize this scheme – Call to mobile number via SIP thought asterisk originate command with dialplan.

I run command:

asterisk -rx "channel originate SIP/79887772211@sip extension 400@dialplan"

And my dialplan:

[dialplan]

exten => 400,1,Answer()

exten => 400,3,Playback(hello-world)

exten => 400,4,Hangup

Now, When I run command I got call on number 79887772211 and when I answer I hear hello world audio.

Now I want to add recall if number 79887772211 is now answer.

I try:

[dialplan]

exten => 400,1,Answer()

exten => 400,3,RetryDial(hello-world|5|3|SIP/79887772211@sip|5|d)

exten => 400,3,Playback(hello-world)

exten => 400,4,Hangup

But it doesn’t work =(

What I do wrong?

9887772211 will always be busy when you call RetryDial (or you will connect it to itself), as it is already connected and answered on the A side.

You might be able to use it in a Local channel on the A side, but any announcements wouldn’t go anywhere useful.

Otherwise use call files, where I think the retry may be automatic.

Thanks for the answer!
Maybe you can tell me how to do it right?
My goal is to make a call to a mobile number through the originate command, and if the subscriber does not answer, then call him back several times and if the call is successful, play the audio file. I can’t use сall files, because I plan to launch originate command via ARI (via post request)

Originate on a local channel, not directly on the target channel.

ok, but how I cant call to 79887772211 in dial plan?
I must use something like this?

[dialplan]

exten => 79887772211,1,Answer()

exten => 79887772211,3,Playback(hello-world)

exten => 79887772211,4,Hangup

I change my dialplan to this:

[outbound]
exten=>_x.,1,verbose( calling to ${EXTEN})
same=>n,Set(CALLERID(num)=${calleridnumber}) ;callerid to use
same=>n,Dial(SIP/${EXTEN}@sip,25) ;trunk to use
same=>n,RetryDial(hello-world|5|3:SIP/${EXTEN}@sip|5|d)

exten=>_xxx,1,verbose( calling to ${EXTEN})
same=>n,Set(CALLERID(num)=${calleridnumber}) ;callerid to use
same=>n,Dial(SIP/${EXTEN},25)

[play]
exten=>s,1,Noop(///${caller}///)
same=>n,Answer()
same=n,Playback(demo-thanks)
same=>n,MusicOnHold(default)
same=>n,Hangup()

And now I can run command:

asterisk -x "channel originate Local/79887772211@outbound extension s@play"

and call works, bit if I drop call, asterisk doesn’t recall me.
Why RetryDial not works?

Because the call completed normally

Now I updated my outbount dialplan to this:

[outbound3]
exten => _x.,1,Dial(SIP/${EXTEN}@sip,15,t)
exten => _x.,2,GotoIf($["${DIALSTATUS}"!="ANSWER"]?redial1)
exten => _x.,3(redial1),Dial(SIP/${EXTEN}@sip,15,t)
exten => _x.,4,GotoIf($["${DIALSTATUS}"!="ANSWER"]?redial2)
exten => _x.,5(redial2),Dial(SIP/${EXTEN}@sip,15,t)

And now if call no answer asterisk recall, but only once.

Why this IF not works?

exten => _x.,4,GotoIf($["${DIALSTATUS}"!="ANSWER"]?redial2)

You will need to provide sufficiently detailed logging, but note that the nett effect of your GotoIf’s is Noop, as both paths end on the same priority.

I edit dialplan and now its works =)

[outbound3]
exten => _x.,1,Dial(SIP/${EXTEN}@sip,15,t)
exten => _x.,n,GotoIf($["${DIALSTATUS}"!="ANSWER"]?redial1)
exten => _x.,n(redial1),Dial(SIP/${EXTEN}@sip,15,t)
   same => n,Set(secondary=79001112233)
   same => n,GotoIf($["${DIALSTATUS}"!="ANSWER"]?redial2)
   same => n(redial2),Dial(SIP/${EXTEN}@sip,15,t)
   same => n,GotoIf($["${DIALSTATUS}"!="ANSWER"]?redial3)
   same => n(redial3),Dial(SIP/${secondary}@sip,15,t)
   same => n,GotoIf($["${DIALSTATUS}"!="ANSWER"]?redial4)
   same => n(redial4),Dial(SIP/${secondary}@sip,15,t)
   same => n,GotoIf($["${DIALSTATUS}"!="ANSWER"]?redial5)
   same => n(redial5),Dial(SIP/${secondary}@sip,15,t)

I use command originate to run it, and everything fine:

channel originate Local/791114442233@outbound3 extension s@play

But when i try to use Asterisk REST API it doesn’t work, why?

curl -v -u admin:admin -X POST "http://127.0.0.1:8085/ari/channels?endpoint=Local/791114442233@outbound3&extension=s@play"

I found answer by myself =)

curl -v -u admin:admin -X POST "http://127.0.0.1:8085/ari/channels?endpoint=Local/791114442233@outbound3&extension=s&context=play"

Thanks everyone for help! =)

With your dialplan, DIALSTATUS will never be ANSWER, and, as I said, even if were ANSWER, the GotoIf would go to the same place as wit would if it hadn’t been.