w0otm
(W0OTM)
December 27, 2020, 4:23pm
1
This topic has been discussed before: ivr-execute-shell-script-php-file/59726
I am wanting to pass the CALLERID and IVR option chosen as a variable to the shell script. (I plan to have the shell script execute a wget to a remote url/php file.
example:
my_script.sh
wget xxxx://server.com/newcaller.php?callerid=XXXXXXXXX&option=2
[mycommand]
exten => s,1,System(/home/asterisk/my_script.sh,$CALLERID,$IVROPTION)
exten => s,n,Return
Am I on the right track? What would be the variable names for CALLERID and IVR Options?
PitzKey
(Itzik)
December 27, 2020, 7:48pm
2
CallerID Variables are documented here Home - Asterisk Documentation
So you would want something like ${CALLERID(num)} or ${CALLERID(all)}
AFAIK $IVROPTION is not a variable, but could be I am wrong.
You have two options:
First. Point each IVR option to a custom destination which will execute a custom dilaplan and then set the return to your final destination.
Second. Do something like as mentioned here:
Here is the dialplan we use , its all added to the extensions_override_freepbx.conf but could be split over overide and custom conf files but prefered to keep in the same place for simplicities sake. Im sure it can be improved upon but it does its job.
[ivr-track]
exten => s,1,Noop(Lets Build our IVR trail ${IVR_trail})
same => n,GotoIf($["${IVR_trail}"=""]?new:again)
same => n(new),Set(__IVR_trail=${IVR_CONTEXT}-Opt-${ARG1})
same => n,Goto(setting)
same => n(again),Set(__IVR_trail=${IVR_t…
In the override file:
[ivr-3]
exten => 1,1,Gosub(ivr-track,s,1(${EXTEN}))
exten => 2,1,Gosub(ivr-track,s,1(${EXTEN}))
exten => 3,1,Gosub(ivr-track,s,1(${EXTEN}))
exten => 4,1,Gosub(ivr-track,s,1(${EXTEN}))
And in extensions_custom.conf
[ivr-track]
exten => s,1,Noop(Entering context in extensions_custom.conf to execute custom dialplan)
exten => s,n,TrySystem(/home/asterisk/my_script.sh ${CALLERID(num)} ${ARG1})
exten => s,n,Set(__ivrreturn=0)
exten => s,n,Return()
Hope that helps
cyberco
(Ian Plain)
December 29, 2020, 12:27pm
3
If all your script is doing is calling a PHP script, I would call that direct from the dialplan using CURL and that way you can get some type of response back as to success or failed for the command similar as to below that we use for opening and shutting a gate
same = n,Set(foo=${CURL(http://gatephone:80/api/switch/ctrl?switch=2&action=off&response=relay2_off )})