Passing control

Hi there,

I’d like to pass control to the next context after hangup ().

The problem is that once you call the hangup (), no further instructions are executed in the dial plan. That is what I have noticed atleast.

I have to call the hangup, but then I have to call another context to do some activity. How can I accomplish this or is there a work around ?

Also, after the hangup, all the variables and their values are lost.

I need to execute a DIAL right after the hangup. But after, the hangup, the channel is dead and the execution stops.

I want to execute another dial plan after hangup and use a dial within it.

Do you want to hangup the calling channel? This is what Hangup() does. If so, then what would the next context do exactly? Some details may help get a good answer

Yes, I want the channel to be hung.

Once the caller hangs up, the next context is going to do a Dial out and call him back.

This is just like a callback. However, this is more customized one.

I am not hands on with AGI scripting. I was thinking if there was a way out.

Call him back from where? You would be calling him back from himself, except that he has already hung up. The channel on which the PBX is running represents the incoming call from him.

I think you are going to have to use a call file to do this. There may be other, sneaky, ways of originating the call back, but I think a call file will be easiest.

I think you will need AGI.


it can be done with 4 lines in the dialplan and a call back script being called by curl.

exten => s,1,Noop(${CALLERID(num)})
exten => s,n,Set(callback=${CURL( … 4&number=${CALLERID(num)})});
exten => s,n,Noop(${callback})
exten => s,n,Hangup()

obviously the guts to do it are in callmeback.php but this will give you an idea of what you are looking to do.


I can handle the dialplan. The only thing that I was trying to avoid was the AGI or any other such script.

That is what my query is, Can I accomplish this with some dialplan? OR is there any dialplan in Asterisk that can work like a CRON ?

Not up to 1.6.x. I haven’t looked at the available options in 1.8. Cron seems rather heavy weight for doing a synchronous call back.


[quote]Can I accomplish this with some dialplan?[/quote] i’ve showed you how, But you will need an external script to fire off the AMI originate,


He actually meant “nothing but dialplan”, but, as you say, it needs more than just dialplan.

I Know :smile: , But I had hoped by showing him hows its done, He might have looked into callabck scripts and realised its fairly simple. :smile:

I know this works as we have customers using it.


OK So there is no way out other than using a PHPAGI or some other script. I thought I could avoid that somehow.

Is it available online somewhere ?

I have done some googling, not much success.

I haven’t tried this. But, what about having an ‘h’ extension in the context containing the Hangup(), and then doing an Originate() from there? What I don’t know is whether Hangup() calls the ‘h’ extension. Also, I don’t know what version brought in Originate().

I am looking for the same thing. That is, after an inside extension completes a call on a trunk, I want to call back that extension. It does seem like it should be easy.

Based on the discussion so far, I will take a look at Originate. I am using 1.8.x.