Hello mates, i would like to know if there is any way to execute an script when a call between 2 local peers ends. I have found about h extension, but the fact is that i want to execute that script when for exaple call between 101 and 102 ends.
I am using a RPI 3b, so if i cant execute that script, i would like to change the output of one pin from “1” to “0”, that could be another solution that I also dont know how to do.
Any help apreciated.
Regards.
As I know you can do it with System
command if u put it before Hangup
command:
exten => _+X.,n,System(/path_to_your_script/script.sh)
exten => _+X.,n,Hangup()
Now that with pin is not enough clean what do you want but I think that it is something what the bash script need to do.
I have tried what u have said, but it didnt result. My code on extensions.conf is:
[intercom]
include => home
exten => 1000,1,NoOp()
exten => 1000,2,SET(CALLERID(name)=Intercom)
same => 3,Set(__DYNAMIC_FEATURES=toggle)
same => 4,Dial(SIP/101&SIP/102)
same => 5,System(/etc/asterisk/bridge.sh)
same => 6,Hangup()
I also have tried to change System line for:
same => n,System(sudo sh /etc/asterisk/bridge.sh)
But it didnt work. If I put all priority order on “n”, the script executes but not the call.
Ill continue trying,
I am looking forward to your response
Regards
Ok i got it. If anyone is interested:[intercom]
[intercom]
include => home
exten => 1000,1,NoOp()
exten => 1000,2,SET(CALLERID(name)=Intercom)
same => 3,Set(__DYNAMIC_FEATURES=toggle)
same => 4,Dial(SIP/101&SIP/102)
exten =>h,1,System(sudo sh /etc/asterisk/bridge.sh)
you need to have the system command in the h extension. If you want to restrict to calls only between 101 and 102, either use dedicated context for 101, and test callerid and ${CDR(dst)} (exten is now h), and IF function
Add a hangup handler to extension 102 before dialing it.
Set(CHANNEL(hangup_handler_push)=sub-bridge,s,1)
[sub-bridge]
exten => s,1,System(sudo sh /etc/asterisk/bridge.sh)
same => n,Return()