TRY THIS Run script based on CID without answering the call

ballsimtall

New Member
Joined
Sep 1, 2013
Messages
3
Reaction score
0
From: http://www.reddit.com/r/Asterisk/comments/1llqhu/run_system_script_based_on_caller_id_without/ (I hope I can get a 2nd opinion from you guys)


This is what I want to do: Depending on who is calling my cell phone, I want to run a different shell script.

My setup: I use freebpx with google voice. Google voice has the ability to call many phones at the same time from one number. Whichever phone picks up the call first will receive the call. I have it so Google voice will call my cell phone and my freepbx at the same time. What I want to happen is that while both phones are ringing, my freepbx will detect the caller ID and be able to run a system script but never actually answer the call. This will allow my cell phone to keep ringing so I can answer the call on my cell phone. The way I have it set up now, freepbx will run the script based on caller ID but it will pick up the call in order to do so, in turn never giving my cell phone a chance to ring.

My extensions_custom.conf file:
;# // BEGIN Thing by CID
exten => 4788,1,Ringing
exten => 4788,2,NoOp(${CALLERID})
exten => 4788,3,System(/root/scripts/thing)
;# // END Thing by CID


;# // BEGIN Thing2 by CID
exten => 4777,1,Ringing
exten => 4777,2,NoOp(${CALLERID})
exten => 4777,3,System(/root/scripts/thing2)
;# // END Thing2 by CID


My freepbx config: Under Admin -> Custom Extentions, I added thing1 and thing 2 Under Admin -> Add Misc Destination, I added thing 1 and thing 2
Under connectivity -> inbound routes I setup two different routes based on caller id to run each extension by going under Set destination -> misc destination and choosing the corresponding "thing" to run.
How can I get the Thing script to run while still ringing my cell phone?
extensions.conf: http://pastebin.com/71aPTyab
extensions_custom.conf: http://pastebin.com/erAhw7DP

UPDATE:
I found the file /etc/asterisk/extensions_additional.conf: At the end of the file reads:

[im-myemailaddressgmailcom]
include => im-myemailaddressgmailcom-custom
exten => s,1(1),Noop(Receiving GoogleVoice on DID: ***My GVoice# was here***)
exten => s,n,Noop(${EXTEN})
exten => s,n,Set(CALLERID(name)=${CUT(CALLERID(name),@,1)})
exten => s,n,GotoIf($["${CALLERID(name):0:2}" != "+1"]?nextstop)
exten => s,n,Set(CALLERID(name)=${CALLERID(name):2})
exten => s,n(nextstop),GotoIf($["${CALLERID(name):0:1}" != "+"]?notrim)
exten => s,n,Set(CALLERID(name)=${CALLERID(name):1})
exten => s,n(notrim),Set(CALLERID(number)=${CALLERID(name)})
exten => s,n,Wait(1) exten => s,n,Answer exten => s,n,SendDTMF(1)
exten => s,n,Goto(from-trunk,***My GVoice # was here***,1)
exten => h,1,Hangup
;--== end of [im-myemailaddressgmailcom] ==--;
So I changed it to:




[im-myemailaddressgmailcom]
exten => s,1,System(/root/scripts/thing)
exten => s,n,Congestion
exten => h,1,Hangup
;--== end of [im-myemailaddressgmailcom] ==--;
And everything ALMOST worked the way I want it!!!!
Problem one: I think this file gets executed no matter what CID is calling. This means I can not make a custom [im-myemailaddressgmailcom] that has a different thing script depending on who is calling. No problem I suppose. Ill just tweak my script to accept parameters and do something like:
[im-myemailaddressgmailcom]
exten => s,1,System(/root/scripts/thingthattakesparams ${CALLERID})
exten => s,n,Congestion
exten => h,1,Hangup
;--== end of [im-myemailaddressgmailcom] ==--;
Correct?




Problem two: At the top of /etc/asterisk/extensions_additional.conf reads:
Do NOT edit this file as it is auto-generated by FreePBX. All modifications to this file must be done via the web gui. There are alternative files to make custom modifications, details at: http://freepbx.org/configuration_files
I take it this means that my changes will get overwritten whenever I restart the PBX? Do you know how I can fix this? Do I need to put [im-myemailaddressgmailcom] somewhere else? If so, how do I make sure it is the very first thing that will run? Is there a better alternative to how I am doing this? Thanks for the help!
 
Can you explain more exactly what you want done on the pbx side when that Google voice number is rung...
 
I want the PBX to run a system level command (a shell script for example). My goal is to have the system run the script while still ringing my cell phone and never actually answering on the PBX. Hope that answered your question.
 
I won't pretend to know what you want to do, it doesn't matter. I think the way to do this is to put your GV trunk(s) in a unique context. Then define this context in extensions_custom.conf with asterisk dial plan that calls your script based on whatever cid rules you want. You have to avoid the answer() command, which you can't control if the call goes to an inbound route.

What do you mean by unique context (how do I do this)?
 

Members online

Forum statistics

Threads
26,686
Messages
174,406
Members
20,257
Latest member
Dempan
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Back
Top