HANGUPCAUSEKEYS , but with Originate command

Hi,

i had a working dialplan based on a DIAL command, if the extension (softphone) was not registered in Asterisk, i send a PUSH message to wake up the softphone, the plan below works great…

exten => 2,1,Set(DIALGROUP(mygroup,add)=PJSIP/6000)
same => n,Set(CURL_RESULT=${SHELL(SOME COMMAND)})
same => n,Wait(1)
same => n,Dial(${DIALGROUP(mygroup)},45)
same => n,Set(HANGUPCAUSEKEYS=${HANGUPCAUSE_KEYS()})
same => n,Set(HANGUP_CAUSE=${HANGUPCAUSE})
same => n,GotoIf($["${HANGUP_CAUSE}" == "1"]?retry)
same => n,GotoIf($["${HANGUP_CAUSE}" == "3"]?retry)
same => n(retry),NoOp(Contact was unreachble, retry dial)
same => n,Set(CURL_RESULT=${SHELL(SOME COMMAND)})
same => n,Wait(3)
same => n,Dial(${DIALGROUP(mygroup)},45)
same => n,NoOp(Dialing failed after second attempt. Hanging up…)
same => n,Hangup()

Now i’m working with a Conference, and using the Originate command to invite someone to the Conference… How can i do the same like i do above, seems the HANGUPCAUSE doesnt work with originate?

exten => 666,1,NoOp()
 same => n,Progress()
 same => n,Wait(1) 
 same => n,Originate(PJSIP/6000,exten,default,777,1,,aC(ulaw,alaw,h264)c(7000)n(Deurbel))
 same => n,Hangup() 
 same => n,ConfBridge(1,myconferenceroom,default_user) 
 
exten => 777,1,NoOp()
 same => n,Progress()
 same => n,Wait(1) 
 same => n,ConfBridge(1,myconferenceroom,admin_user)

Thnx in advance!!

The easiest option would be to dial a Local channel instead, so that the dialplan logic executes such as “Local/2@context”. Where context is the context, of course.

Ah , is that all, what is the difference then?
I only need to change in the originate command then…

The difference is that calling “PJSIP/6000” in Originate means to call that PJSIP endpoint. No dialplan executes until answer. Calling “Local/2@context” in Originate means to call the extension in the dialplan, as if that extension in the dialplan had been called by another device.

Ah , so the hangupcause only works within a dialplan then? Ok , didn’t know that…

Asterisk all new to me , still learning

ok, i do some trial and error, thnx for feedback

Hangup cause only works if you access the channel after the hang up. If the A side of originate fails, the call ends there, and the B side isn’t run. Also, for the value to be copied from one channel to another, as would be the case in your original code, something has to do that, and that is normally the DIal() or Queue() application. Similarly, if an outgoing channel can’t be created, that something has to set hangup cause for it.

yes, ty
i have it working now creating with local, thnx for you both!!

@david551 or @jcolp

One other question, i can do a CURL command when i call extension “1” , it can open a doorlock

exten => 1,1,NoOp()
 same => n,Set(CURL_RESULT=${SHELL(curl -i --digest -u admin:xxx -X PUT -d '<RemoteControlDoor><cmd>open</cmd></RemoteControlDoor>' http://ip)

How can i do that during a call?
Leys Say , 6001 , calls to 6002 … when call is estabilished, can i open the door?
I tried pressing #1 OR 1 during a call, but nothing happens

Is that possible?

nm, i can use a blind transfer it seems…

  • T : Allow the calling user to transfer the call by hitting the blind xfer keys (features.conf). Does not affect transfers initiated through other methods, however you won’t be able to include other post-answer options to your call in addition to this one.
    • If you have set the variable GOTO_ON_BLINDXFR then the transferrer will be sent to the context|exten|pri (you can use ^ to represent | to avoid escapes), example: SetVar(GOTO_ON_BLINDXFR=woohoo^s^1); works with both t and T
  • t : Allow the called user to transfer the call by hitting the blind xfer keys (features.conf) Does not affect transfers initiated through other methods.
    • If you have set the variable GOTO_ON_BLINDXFR then the transferrer will be sent to the context|exten|pri (you can use ^ to represent | to avoid escapes), example: SetVar(GOTO_ON_BLINDXFR=woohoo^s^1); works with both t and T

You would normally do things like that using feature codes in features.conf. I would make sure the curl didn’t block for any significant time.

1 Like

yeah, the proprblem is that i’m indeed sending with “1" its a predefined button on my softphone
but i think its too quick… i also tried like "
,1” like a delay, but thats not working either

can i just remove the suffix or some otherway, so by pressing “1” during call, the curl is activated?

[featuremap]
blindxfer => *                ; Blind transfer  (default is #) -- Make sure to set the T and/or t option in the Dial() or Queue() app call!

You can make 1 be a feature code.

hmm , how? without the transfer then? not following :slight_smile:

1 Like

i was trying this like:

[applicationmap]
door => 2,peer,Macro,opendoor

in extensions.conf i have:

[default]
exten => 64669,1,NoOp()
 same => n,Set(__DYNAMIC_FEATURES=door)
 same => n,Dial(PJSIP/64669,,t)

[macro-opendoor]
exten => s,1,Set(CURL_RESULT=${SHELL(XXX)})
 same => n,n,MacroExit

When i call 64669 , and press “2” during call , i get :

 [Jun  1 17:10:05] WARNING[628][C-00000001]: app.c:277 ast_app_exec_macro: Cannot run 'Macro(opendoor)'.  The application is not available.
[Jun  1 17:10:05] WARNING[628][C-00000001]: app.c:277 ast_app_exec_macro: Cannot run 'Macro(opendoor)'.  The application is not available.

What am i missing? :slight_smile:

nm, got it, i can use the Dial app, instead of macro :slight_smile:

I would have assumed you wanted to use Curl or System. When I press the release button on my entry intercom (non digital), it doesn’t cut off the phone.

ah you mean here?

door => 9,self,dial,Local/9@default

Can i use there something else instead of “dial” ?

edit:indeed, using “set” there, thats better :slight_smile:
thnx

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.