Performing Action on User Hangup

Hi all,

I’m a relative newcomer to Asterisk but I’ve got some interesting ideas for possible uses to which I could put my installation :smile:.

I’m running Debian “testing” with the Asterisk package (1.2.13) installed, and all is configured and running to my liking. I’ve got an account and 0845 number (that’s a local rate number in the UK) with sipgate.co.uk and that’s all working perfectly.

So, on to the ideas. The one I’m currently stuck on goes something like this: say I find myself with hardly any calling credit on my mobile phone but want to make a call, or access an application on my Asterisk box. I would like to be able to call my * box, have it recognise that it’s my mobile number calling, wait a few rings so I can hang up, then call me back. It could then present me with an internal dialtone or a menu or whatever.

The logic problem I’m having just thinking about this in the planning stage is how to do something upon my hanging up. Recognising the number seems simple enough, but to actually execute an action (such as initiating another call) when I hang up seems to be problematic. I found this thread on one of the Digium lists which seems to suggest it’s not that easy/possible in AGI; can anyone shed any light on this? AGI is not something I’ve dabbled with yet; I’m still playing around with the standard applications/actions.

Maybe it’s better that I use a few pence call credit to access a short menu where I can request a callback :stuck_out_tongue:. What do you think?

Thanks for reading. I hope I provided enough contextual info; if not, please ask! Thank you again,

Biggs

Hi
Have a google, You will find what you want to do has been done many times and you will find various methods of doing what you want.

Ian

we run an agi script after a call has been hungup to allow our application to perform post processing.

We use ruby scripts for AGI as you can see below.

for example:

exten => _9995551212,1,Ringing 
exten => _9995551212,2,Set(Cleanup=TRUE)
exten => _9995551212,3,deadagi,agi_script.rb

; default handling for hangups only
exten => h,1,NoOp("In hangup case")
exten => h,2,GotoIf($[${Cleanup} = "TRUE"]?3:4)
exten => h,3,deadagi,agi_cleanup_script.rb
exten => h,4,Hangup

If you write this in your extensions.conf file, then you can do some processing using an AGI script after a hangup.

I have also started using adhearsion as a replacement for traditional AGI.
Adhearsion has a really really cool way of letting you handle operations after a hangup. I highly suggest looking into it. It uses ruby code block like this:

begin
  # your code here and application
ensure
  # your code that must be executed after a hangup
end

All this gets excuted after making a call to a fastagi script served by adhearsion. Very cool and very clean.