Development Question: Keeping a call active after hangup


I am setting up a system which needs to do the following and am wondering the best way to go about it:

A caller will be brought through a serious of IVRs and will enter which option they want with normal DTMF. At a certain point the caller will be transfered to an Agent. Before the agent talks to the caller he/she will need to be played a recording. If at any stage the caller hangs up an anouncement will need to be played to the Agent.

The playing the announcements are ok but my problem is more with the hangup part, how to keep a call active after 1 party hangs up? I was thinking of using MeetMe but this causes its own problems like how to get the caller and agent into the meetme room and how to make the recordings dynnamic.

I am not using freepbx or anything, everything will be done in asterisk backend. Just wondering if anybody would have any suggestions?

Many thanks,

You can set a series of actions using the “h” action in the dialplan.

exten XX,1,Answer()
exten XX,n,Wait(3)
exten XX,n,Background(whatsup)
exten XX…
exten XX,n,Hangup()

exten XX,h,AGI(contact_agent.agi)

Not as clear as O’reilly, but what do you want for free?

Thanks for the quick reply. Never thought about it and will give it a go.

Would the ‘h’ option not require the call to end completly before the hangup action is done.

I was hoping that the agent will be played a recording before the call ends completly.

For example:

  • Caller A calls Agent
  • Agent Answers
  • Caller A hangsup
  • System plays a recording to the agent
  • Call hangsup

Thanks again

When in the h extension use DeadAGI.

Hi Chris,

Thanks for that. I have made progress with your suggestion. There is one problem though.

Everything works in this scenario:

  • Caller calls and is connected to an Agent
  • Agent Hangs up
  • Caller is played a message

However if the caller hangs up first the agent is not played a message.

Would anybody know how to fix this? One way i tried was to get an agi script to catch signal.SIGHUP to stop it ending the call but i cant get it to work. I have included a format of my code below

import signal,sys
signal.signal(signal.SIGHUP, do_something)
sys.stdout.write("EXEC Dial SIP/202\n")

Thanks again for any help.

g: When the called party hangs up, exit to execute more commands in the current context.

asterisk cmd dial option