Friday, September 8, 2017

Have callers approve their call being recorded in Asterisk.




This a demo, so I just used a default recording that says "this call may be monitored". You can easily replace this with one that makes more sense. "Press 1 to permit us to record this call, any other key to decline"
Pressing 1 will FORCE recording of the calls. Any other key, or if they press nothing after a couple of asks it will automatically set the recording to "NO"
This works for all calls marked as external. Internal calls I've bypassed it asking the question and set it to 'dontcare'. If you want internal extension to extension calls record, change 'dontcare' to 'force'
ASSUMPTION
You've set all call recording options in FreePBX to "DONT CARE"
Thats how i tested it. In FreePBX Distro 10.13.66
INSTALLATION
Don't test this in production environment

Open up extension_additional.conf and look for the context
[sub-record-check]
Copy that entire section (its probably about 100 lines) and ends with
;--== end of [sub-record-check] ==--;
Paste that into extensions_override_freepbx.conf
Find these two lines about 12 or so lines down.
exten => recordcheck,1,Noop(Starting recording check against ${ARG1})
exten => recordcheck,n,Goto(${ARG1})
INSERT these 4 lines in between the above two lines.
exten => recordcheck,n,GotoIf($["${CALLTYPE}" = "internal"]?dontcare)
exten => recordcheck,n,ExecIf($["${CALLTYPE}" = "external"]?Read(FOOrecord,this-call-may-be-monitored-or-recorded,1,,2,3))
exten => recordcheck,n,ExecIf($["${CALLTYPE}" = "external" | "${FOOrecord}" = "" ]?Set(ARG1=no)
exten => recordcheck,n,ExecIf($["${CALLTYPE}" = "external" | "${FOOrecord}" = "1" ]?Set(ARG1=force)
Save your changes
Reload the config
Make a test call.
CODE EXPLAINED:
Check to see if its an internal extension to extension call, we bypass it asking for permission to record and ring the phone.
exten => recordcheck,n,GotoIf($["${CALLTYPE}" = "internal"]?dontcare)
If this is an external call, we prompt the caller if they permit us to record the call. the syntax is:
READ(DTMFvariable, soundfile, max number of digits, number of times it will ask, how long it will wait for an answer
exten => recordcheck,n,ExecIf($["${CALLTYPE}" = "external"]?Read(FOOrecord,this-call-may-be-monitored-or-recorded,1,,2,3))
If the caller doesn't respond with any input, then we assume "no" and continue the call. 
exten => recordcheck,n,ExecIf($["${CALLTYPE}" = "external" | "${FOOrecord}" = "" ]?Set(ARG1=no)
If the callers presses 1, then we set the call recording to on and ring the extension
exten => recordcheck,n,ExecIf($["${CALLTYPE}" = "external" | "${FOOrecord}" = "1" ]?Set(ARG1=force)

No comments:

Post a Comment