No callback through same port?


I’d like to have Asterisk wait for calls on the FXO port (without answering: The remote end just rings Asterisk a couple of times so Asterisk can pick up CID), hangup/wait, then call the user back through the FXO port.

I’m puzzled as to why this doesn’t nothing:

exten => s,1,Wait(2)
exten => s,n,Hangup()

;doesn't wait 10 seconds, just displays "Hungup"
exten => h,1,Wait(10)
exten => h,n,Dial(Zap/1/123456)

;Alternative: Doesn't work any better
exten => h,1,Wait(10)
exten => h,n,Dial(Local/start@callback)

exten => start,1,Dial(Zap/1/123456)

Has someone successfully built a callback feature in Asterisk? If it’s just not possible, I was thinking of adding an “at” job + “asterisk -rx originate”, but it’s bit of a kludge.

Thanks for any help.

Because you have no incoming channel on which to run the Dial application.

Basically, you use AMI Originate. If you search ianplain’s postings, you will see more details on this, e.g. tricks for getting the dialplan to start the AMI application.


Yes :wink:

Basicly the stages are.
1 get the cli of the incoming call (without answering)
2 Pass this to an external script
3 Hangup the call
4 The script by now will be running and will originate a call via (or call file) to the number passed to it
5 make the calls.

The script can be simple or as complicated as you want, Ours is complicated as we have the option to tweet, email people, also all calls are stored in a mysql database as is the internal destination.


Thanks David. According to this thread, Ian’s solution involves 1) an AGI script to 2) call Asterisk through the AMI and use the “originate” command that was introduced in 1.6. Unfortunately, I’m stuck with a 1.4 :confused: … +Originate

Is there another way, ideally from within the dialplan?

Thank you.


  1. an AGI script to 2) call Asterisk through the AMI and use the “originate” command that was introduced in 1.6. Unfortunately, I’m stuck with a 1.4

Oh no it doesnt, and we have been doing this since 1.0

Look at what I posted above and in that thread.


Our messages missed each other. Apparently, “originate” was introduced in AMI in 1.6 but is available from an AGI since 1.0

Since this is an Asterisk appliance, I can’t use a big language like PHP, so I’ll try building a Lua script to make a call through AGI.

Thanks guys.

AMI Originate is in TFOT. It must be in 1.4!

Sorry about this. That page says “Originate: Originate Call (privilege: call,all) NOTE: starting from 1.6: originate,all”, so I thought it meant I was out of luck with a 1.4.

ip04*CLI> manager show commands
  Action           Privilege        Synopsis
  ------           ---------        --------
  Originate        call,all         Originate Call

So I’ll just have to learn how to call a Lua script through AGI to use Originate().

Thank you.

I’m still curious, though, about why Asterisk can’t call back through the FXO when setting up a second channel thusly:

exten => s,1,Wait(2)
exten => s,n,Set(CID=${CALLERID(num)})
exten => s,n,NoOp(Call from ${CID})
exten => s,n,Hangup()

exten => h,1,Wait(10)
exten => h,n,Dial(Local/start@callback)

exten => start,1,Verbose(In callback)
exten => start,n,Dial(Zap/1/${CID})
exten => start,n,Hangup

Here’s the console:

-- Starting simple switch on 'Zap/1-1'
-- Executing [s@from_fxo:1] Wait("Zap/1-1", "2") in new stack
-- Executing [s@from_fxo:2] Set("Zap/1-1", "CID=123456") in new stack
-- Executing [s@from_fxo:3] NoOp("Zap/1-1", "Call from 123456") in new stack
-- Executing [s@from_fxo:4] Hangup("Zap/1-1", "") in new stack
== Spawn extension (from_fxo, s, 4) exited non-zero on 'Zap/1-1'
-- Executing [h@from_fxo:1] Wait("Zap/1-1", "10") in new stack
== Spawn extension (from_fxo, h, 1) exited non-zero on 'Zap/1-1'
-- Hungup 'Zap/1-1'

Does someone know the innards of Asterisk and could shed some light?

Thank you.

As I already said, the party A channel has hungup, so cannot initiate a dial. In any case, what would you expect the party B channel to be connected to?

You are the second person with this same misunderstanding, recently.

Exactly as David said, and Ive told you how to do it , We know it works, otherwise there would be lots of very unhappy chauffeurs out there :wink:


I guess it’s not obvious.

Bottom line: Once a channel leads us to the dialplan, we simply cannot reuse it with Dial() from within the dialplan, even by calling Hangup() and/or jumping to another context through a local channel. Hence the need to make the callback from an outside script. It looked simple on paper.

Thank you.