Out of Hours Calls Pin Code System


(United Kingdom) #1

I’m looking to create a good way of managing and controlling incoming calls during out of work hours.

Context: My customers pay extra to have the ability to call me outside of work hours. I want to give them a pin code that allows calls through, and remembers the CID they called from, and won’t prompt that CID for a pin code again. Each customer has a unique pin code. Ideally I’d like this to be managed through GUI somehow, but I’m very aware that’s likely not going to be possible!

As it stands, I have an inbound route from a “Out of Hours” DID going to a small custom destination I found somewhere online (I’m afraid I forgot exactly where, see below). The pinset_1 file I currently manually update as needed when new customers are added or removed, and the pin must be entered each time. I’d love some help in figuring out how to modify this to (in order of priority):
A) Not prompt previous successful CIDs
B) Not need me to go in and manually update a text file
C) Have the ability to remove the whitelisted CIDs related to a specific PIN code - i.e. Customer doesn’t pay, they get booted off.

Thanks in advance for any pointers!

[sub-inbound-auth]
exten => s,1,Wait(2)
exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/pinless)}" != “NOPASSWD”]?Authenticate(/etc/asterisk/pinset_1,am))
exten => s,n,Set(__PINNUMBER=${CDR(accountcode)})
exten => s,n,NoOp(Pin number is ${PINNUMBER})
exten => s,n,Set(CALLERID(name)=EM:${CDR(accountcode)})
exten => s,n,Return()

edit: Bonus points if different “Categories” of pin code could be sent to different destinations! E.G, A customer with 24/7 support always gets through, a customer with 18/5 support goes to a time condition first, etc.


#2

Pertinent priorities from my ‘whitelisting’

same => n,GotoIf($[${ISNULL(${DB(whitelist/${CALLERID(num)})})}]?:ok)                                                  
.                                                                                                                      
.                                                                                                                      
.                                                                                                                      
.                                                                                                                      
same => n(addwhitelist),Set(DB(whitelist/${CALLERID(num)})=${EPOCH})                                                   
.                                                                                                                      
.                                                                                                                      
.                                                                                                                      
same => n(ok),goto(from-pstn,${FROM-DID},1)                                                                            
.                                                                                                                      
.                                                                                                                      

(United Kingdom) #3

Thanks, that works great.
I’ve (lightly!) modified your priorities to store the Pin that was entered rather than EPOCH.
This Configuration works for me, to allow me to purge a whitelisted item with a feature code as well.

[sub-inbound-auth]
exten => s,1,Wait(2)
same => n,GotoIf($[${ISNULL(${DB(whitelist/${CALLERID(num)})})}]?:ok)
same => n,NoOp(CID not in Whitelist, Prompting for PIN...)
same => n,Playback(custom/Code-Ready&custom/Code-Ready-2&custom/Code-Ready-3,noanswer)
same => n,ExecIf($["${DB(AMPUSER/${AMPUSER}/pinless)}" != “NOPASSWD”]?Authenticate(/etc/asterisk/pinset_1,am))
same => n,Set(__PINNUMBER=${CDR(accountcode)})
same => n,NoOp(Pin number is ${PINNUMBER})
same => n,NoOp(Adding ${CALLERID(num)} to Whitelist...)
same => n(addwhitelist),Set(DB(whitelist/${CALLERID(num)})=${PINNUMBER})
same => n(ok),Return()

[sub-inbound-auth-purge]
exten => s,1,Set(array=$[${DB_KEYS(whitelist)}])
same => n,Set(count=0)
same => n,READ(pin)
same => n,While($["${SET(num=${SHIFT(array)})}" != ""])
same => n,GotoIf($[DB(whitelist/${num})=${pin}]?:loop)
same => n,NoOp(Removing ${num} from whitelist...)
same => n,DB_DELETE(whitelist/${num})
same => n,Set(count=$[${count}+1])
same => n(loop),EndWhile
same => n,SayNumber(count)
same => n,Playback(beep)
same => n,Hangup()