Asterisk phone lock/unlock feature

Below is a simple and intuitive dialplan by which you can add the phone lock feature to your Asterisk system. Take note that the provided dialplan only locks the phone from calling out to PSTN.

If you’re using FreePBX follow these steps:

  1. Add this code snippet to /etc/asterisk/extensions_custom.conf and reload Asterisk Dialplan.
  2. Create 2 custom destinations and point it to these 2 contexts.
  3. Add a new Misc application with whatever feature codes you like. (in this case I used *50 and *51)
; feature code: *50
; clear KeyLock PIN
[custom-keylockclear]
exten => s,1,Answer
exten => s,n,PlayBack(silence/1&ha/phone&ha/locked)
;exten => s,n,AGI(vm-password.php,${CALLERID(num)}@default)
exten => s,n,VMAuthenticate(${CALLERID(num)}@default)
exten => s,n,Set(DEVICENUM=${DB(DEVICE/${CALLERID(num)}/user)})
exten => s,n,Set(CIDNUM=${DB(AMPUSER/${DEVICENUM}/cidnum)})
exten => s,n,Set(DB(AMPUSER/${CIDNUM}/KEYLOCK)=)
exten => s,n,PlayBack(ha/phone&ha/unlocked)
exten => s,n,Hangup

; feature code: *51
; set KeyLock PIN
[custom-keylockset]
exten => s,1,Answer
exten => s,n,PlayBack(silence/1)
exten => s,n,Set(DEVICENUM=${DB(DEVICE/${CALLERID(num)}/user)})
exten => s,n,Set(CIDNUM=${DB(AMPUSER/${DEVICENUM}/cidnum)})
exten => s,n,Set(DB(AMPUSER/${CIDNUM}/KEYLOCK)=1)
;exten => s,n,PlayBack(pin-number-accepted)
exten => s,n,PlayBack(ha/phone&ha/locked)
exten => s,n,Hangup

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *