Dedicated Hangup Extension H

Home » Asterisk Users » Dedicated Hangup Extension H
Asterisk Users 5 Comments

Hello,

We have a Kamailio SIP Proxy in front of our Asterisk cluster for incoming calls from our carrier.

The sip.conf looks like this:

[kamailio1]
type=friend host=10.0.0.1
context=incoming disallow=all allow=alaw

All calls hit the incoming extension. In the extensions.conf we have multiple extensions configured, but now I have to add one which uses the special h extension to perform a CURL action whenever the user hangs up. The problem is that once I’ve registered a h extension, it is executed for all extensions in the incoming context.

exten => _X.,1,Playback(invalid)
exten => _X.,n,Hangup

exten => 1000,1,Playback(welcome)
exten => 1000,n,Read(dtmfinput,,,,,15)
exten => 1000,n,Hangup

exten => h,1,Set(response=${CURL(http://sample.company.local/PostHandler.ashx,var1=${dtmfinput}&var2=1000)})

Is it possible to give each extension its own h extension? If not, is there another way to do this?

5 thoughts on - Dedicated Hangup Extension H

  • Hi Grant!

    I do not know of a way to have multiple ‘h’ extensions in the same context.

    But you can easily make an appropriate context for your custom need!

    exten => _X.,1,Playback(invalid)
    exten => _X.,n,Hangup

    exten => 1000,1,Noop(Go to CURL Hangup)
    exten => 1000,n,Goto(CURL_Hangup,${EXTEN},1)

    ; ….. your context goes on ….

    ; Added Custom Context

    [CURL_Hangup]

    exten => _X.,1,Playback(welcome)
    exten =>_X.,n,Read(dtmfinput,,,,,15)
    exten =>_X.,n,Hangup

    exten => h,1,Set(response=${CURL(http://sample.company.local/PostHandler.ashx,var1=${dtmfinput}&var200)})

    HTH, Aldo

  • Yes, that’s exactly what I needed. Totally forgot about doing that kind of a construction.

    Thank you very much!

    —–Original Message—

  • I would set a “no-use” flag in all extensions that you do not want to use the h, and then test for it in the h extension itself – if it is set you could just run the Hangup application.

  • The magic you’re looking for exists in Asterisk 11: https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers

    Basically, instead of h extensions, that fire based on what context the call ended in (and fire for all extensions in that context), you attach a handler to the call at some point (such as, when it enters a specific extension). At the end of the call, each hangup handler fires as a Gosub, in reverse order of how they were added (the last one added fires first). Life gets a little entertaining if you’re trying to remove hangup handlers and don’t remember what order they went on in (your removal choices are either the last one added or all of them), but for what you’re describing as what you need, hangup handlers should work fairly well.

    Thank you,

    Noah Engelberth MetaLINK Technologies

    From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Grant Bagdasarian Sent: Wednesday, August 28, 2013 3:51 AM
    To: asterisk-users@lists.digium.com Subject: [asterisk-users] Dedicated hangup extension h

    Hello,

    We have a Kamailio SIP Proxy in front of our Asterisk cluster for incoming calls from our carrier.

    The sip.conf looks like this:

    [kamailio1]
    type=friend host=10.0.0.1
    context=incoming disallow=all allow=alaw

    All calls hit the incoming extension. In the extensions.conf we have multiple extensions configured, but now I have to add one which uses the special h extension to perform a CURL action whenever the user hangs up. The problem is that once I’ve registered a h extension, it is executed for all extensions in the incoming context.

    exten => _X.,1,Playback(invalid)
    exten => _X.,n,Hangup

    exten => 1000,1,Playback(welcome)
    exten => 1000,n,Read(dtmfinput,,,,,15)
    exten => 1000,n,Hangup

    exten => h,1,Set(response=${CURL(http://sample.company.local/PostHandler.ashx,var1=${dtmfinput}&var2=1000)}< http://sample.company.local/PostHandler.ashx,var1=$%7bdtmfinput%7d&var2=1000)%7d>)

    Is it possible to give each extension its own h extension? If not, is there another way to do this?

  • Thanks, I’ll take a look at that too.

    From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Noah Engelberth Sent: Wednesday, August 28, 2013 1:29 PM
    To: Asterisk Users Mailing List – Non-Commercial Discussion Subject: Re: [asterisk-users] Dedicated hangup extension h

    The magic you’re looking for exists in Asterisk 11: https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers

    Basically, instead of h extensions, that fire based on what context the call ended in (and fire for all extensions in that context), you attach a handler to the call at some point (such as, when it enters a specific extension). At the end of the call, each hangup handler fires as a Gosub, in reverse order of how they were added (the last one added fires first). Life gets a little entertaining if you’re trying to remove hangup handlers and don’t remember what order they went on in (your removal choices are either the last one added or all of them), but for what you’re describing as what you need, hangup handlers should work fairly well.

    Thank you,

    Noah Engelberth MetaLINK Technologies

    From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Grant Bagdasarian Sent: Wednesday, August 28, 2013 3:51 AM
    To: asterisk-users@lists.digium.com

    Subject: [asterisk-users] Dedicated hangup extension h

    Hello,

    We have a Kamailio SIP Proxy in front of our Asterisk cluster for incoming calls from our carrier.

    The sip.conf looks like this:

    [kamailio1]
    type=friend host=10.0.0.1
    context=incoming disallow=all allow=alaw

    All calls hit the incoming extension. In the extensions.conf we have multiple extensions configured, but now I have to add one which uses the special h extension to perform a CURL action whenever the user hangs up. The problem is that once I’ve registered a h extension, it is executed for all extensions in the incoming context.

    exten => _X.,1,Playback(invalid)
    exten => _X.,n,Hangup

    exten => 1000,1,Playback(welcome)
    exten => 1000,n,Read(dtmfinput,,,,,15)
    exten => 1000,n,Hangup

    exten => h,1,Set(response=${CURL(http://sample.company.local/PostHandler.ashx,var1=${dtmfinput}&var2=1000)}< http://sample.company.local/PostHandler.ashx,var1=$%7bdtmfinput%7d&var2=1000)%7d>)

    Is it possible to give each extension its own h extension? If not, is there another way to do this?