Skip to content

Instantly share code, notes, and snippets.

@lgaetz
Last active July 11, 2025 16:53
Show Gist options
  • Save lgaetz/feaedc65a2f255bb4027e2b52efa8947 to your computer and use it in GitHub Desktop.
Save lgaetz/feaedc65a2f255bb4027e2b52efa8947 to your computer and use it in GitHub Desktop.
; Purpose
; FreePBX custom in-call feautre code framework that allows a caller to initiate an action that will be performed on hangup by
; pressing #9 during a call. Sets up feature code that adds a hangup handler to the channel, and the hangup handler can be used
; to record to the CDR userfield or perform some other action Possible uses are for flagging calls with audio issues.
;
; Latest version: https://gist.github.com/lgaetz/feaedc65a2f255bb4027e2b52efa8947
;
; License GNU GPL3+
;
; History 2021-11-03 First Commit
; 2025-07-11 Added hangup handler with full log and recording to email
; in /etc/asterisk/globals_custom.conf
DYNAMIC_FEATURES = ${DYNAMIC_FEATURES}#flagger
; in /etc/asterisk/features_applicationmap_custom.conf
flagger => #9,self,Set(CHANNEL(hangup_handler_push)=flagger,s,1)
; in /etc/asterisk/extensions_custom.conf
[flagger]
exten => s,1,Noop(Entering user defined context flagger in extensions_custom.conf)
exten => s,n,Set(CHANNEL(hangup_handler_push)=flag-call-complete,s,1)
; add additional lines as required
exten => s,n,Return
[flag-call-complete]
exten => s,1,Noop(Entering user defined context flag-call-complete in extensions_custom.conf)
; exten => s,n,DumpChan ; uncomment for debug
; isolate full log lines for the UNIQUEID in question, dump to temp file and attach it and the call recording to an outgoing email
exten => s,n,set(full-log-id=${TRIM(${SHELL(grep \"TOUCH_MONITOR=${UNIQUEID}\" ${ASTLOGDIR}/full | cut -d '[' -s -f 4 | cut -d ']' -f 1)})})
exten => s,n,System(grep ${full-log-id} ${ASTLOGDIR}/full > ${ASTSPOOLDIR}/${UNIQUEID})
exten => s,n,System(mail -s 'FLAGGED CALL ${UNIQUEID}' -a ${ASTSPOOLDIR}/${UNIQUEID} -a ${MIXMONITOR_FILENAME} [email protected] )
exten => s,n,Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment