Whitelist added to my ‘nonsense’
A successful question and answer session takes all of 15 seconds, so not too obnoxious (and certainly not complex). You can wrap those couple of “DB” lines around any other “Intrusion detection system” you want to make it a one-time only thingy :-
[bender-blocker-whitelist-and-google-tts]
exten => s,1,noop(Google Cloud STT and whitelist)
same => n,GotoIf($[${ISNULL(${DB(whitelist/${CALLERID(num)})})}]?:ok); are they whitelisted yet
same => n,Set(loop=0)
same => n,Set(prefix=${EPOCH})
same => n(loop),Playback(custom/screening)
same => n,Record(/tmp/${prefix}number.wav,2,3)
same => n,Set(voice=${SHELL(gcloud ml speech recognize /tmp/${prefix}number.wav --language-code='en-US'|sed -n -e '/transcript/p'|sed -e 's/[^0-9]*//g' -e 's/.*\([0-9]\{2\}$\)/\1/'|tr -d '\n')})
same => n,GotoIf($[ ${LEN(${voice})} < 2 ]?invalid)
same => n,Read(keypad,custom/verify,2,,,2)
same => n,GotoIf($["${voice}" = "${keypad}"]?addwhitelist) ; did they pass the password check?
same => n(invalid),PlayBack(custom/wronganswer)
same => n(break),Set(loop=$[${loop}+1])
same => n,GotoIf($["${loop}"="3"]?finish:loop)
same => n(finish),Playback(sorry-youre-having-problems)
same => n,Hangup()
same => n(addwhitelist),Set(DB(whitelist/${CALLERID(num)})=OK) ; ok they passed the one-time nonsense, whitelist this number
same => n(ok),goto(from-pstn,${FROM-DID},1) ' ; this is where the good-guys get to go. It could be a QUEUE or an IVR of course
To preemptively add granny’s number (555-222-1234) so she doesn’t need to go through this pain
rasterisk -x "database put whitelist 5552221234 Granny"
Suggested content of custom/screening.wav “This is Robocallcop, just once I ask you to say a number between 11 and 99”
Suggested content of custom/verify.wav “Thank, you, now please enter that same number on your dialpad”
Suggested content of custom/wronganswer.wav " Sorry, Invalid response"
All done in your best RoboCop voice of course.