Skip to content

Instantly share code, notes, and snippets.

@lgaetz
Last active April 19, 2022 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgaetz/b65d7ec29d2e2cba46909051dfcb39cf to your computer and use it in GitHub Desktop.
Save lgaetz/b65d7ec29d2e2cba46909051dfcb39cf to your computer and use it in GitHub Desktop.
; FreePBX custom dialplan that creates a prefix dial code that
; will keep an asterisk channel open for 3600 seconds to monitor
; the device state of the target local extension and call back once
; the target extension is idle
; License GNU GPL3
;
; Latest version: https://gist.github.com/lgaetz/b65d7ec29d2e2cba46909051dfcb39cf
;
; History
; 2022-03-23 Crude but working proof of concept
[watcher]
exten => _X.,1,Noop(Entering user defined context watcher in extensions_custom.conf)
exten => _X.,n(start),Wait(10)
exten => _X.,n,Noop(Extension state of ${callee} is: ${EXTENSION_STATE(${callee}@ext-local)})})
exten => _X.,n,GotoIf($["${EXTENSION_STATE(${callee}@ext-local)}"!="NOT_INUSE"]?start)
exten => _X.,n,Goto(from-internal,${caller},1)
[from-internal-custom]
exten => _**45XXXX,1,Noop(Entering user defined context from-internal-custom in extensions_custom.conf)
exten => _**45XXXX,n,Macro(user-callerid)
exten => _**45XXXX,n,Set(caller=${AMPUSER})
exten => _**45XXXX,n,Set(callee=${EXTEN:4})
exten => _**45XXXX,n,Originate(local/${caller}@watcher,exten,from-internal,${callee},1,3600,av(caller=${AMPUSER}^callee=${EXTEN:4}))
; exten => _**45XXXX,n,Answer ; in this section we can play a recording to the caller indicating watch is set
; exten => _**45XXXX,n,Wait(.5)
; exten => _**45XXXX,n,Playback(enabled)
exten => _**45XXXX,n,Hangup
@lgaetz
Copy link
Author

lgaetz commented Mar 23, 2022

Version 1 - proof of concept.

  • Needs checks to prevent call from going to voicemail or to a non-human
  • no way to check status of watcher or cancel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment