Skip to content

Instantly share code, notes, and snippets.

View lgaetz's full-sized avatar

Lorne Gaetz lgaetz

  • Nova Scotia, Canada
View GitHub Profile
@lgaetz
lgaetz / remotehintpoll.php
Last active December 7, 2025 01:50
Simple PHP script that checks the extension status at a remote PBX and updates a custom hint on the local pbx for proper BLF operation.
<?php
/**** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ****
* remotehintpoll.php
*
* Created by Lorne Gaetz lgaetz@sangoma.com
*
* Latest version: https://gist.github.com/lgaetz/8545099
*
* Licensed under GNU GPL version 2 or any later verison.
@lgaetz
lgaetz / Targeted ChanSpy
Last active October 9, 2025 12:36
FreePBX Feature code prefix to allow spy/whisper/barge on the specified extension
; FreePBX Feature code prefix to allow spy/whisper/barge on
; the specified extension.
;
; Latest version:
; https://gist.github.com/lgaetz/78c4e114952e79596c1ed4123559d3d3
;
; Usage:
; Dialplan goes in the file:
; /etc/asterisk/extensions_custom.conf
; Dial local extension with 556 prefix to spy. While spying on
@lgaetz
lgaetz / lgaetz-callfile
Last active September 19, 2025 17:58
Gentleman Caller
; FreePBX dialplan to schedule a call for future using Asterisk call file.
;
; License: GNU GPL3+
; latest version: https://gist.github.com/lgaetz/ec3509da8d989a00064337f194b9d58e
;
; Asterisk diaplan sub requires 3 arguments
; ARG1 = dialstring for first leg of call
; ARG2 = dialstring for second leg of call
; ARG3 = how many minutes in the future to schedule the call
;
[send-sip-response-code]
; Context to send a specific SIP response code and terminate the channel
; Create Custom Destination in FreePBX with a dial string of the format
; send-sip-response-code,404,1
; substitute the appropriate response code in place of the 404
; Reference: https://wiki.asterisk.org/wiki/display/AST/Hangup+Cause+Mappings
;
; IMPORTANT: This dialplan is superseded by the native Asterisk applicaton PJSIPHangup
;
; latest version: https://gist.github.com/lgaetz/480582a1827cc98db1ee539c249f074b
@lgaetz
lgaetz / sendmail-bluemix
Last active July 31, 2025 03:30
Asterisk voicemail mailcmd script for VM transcription
#!/bin/sh
# sendmail-bluemix
# current verison of this script: https://gist.github.com/lgaetz/2cd9c54fb1714e0d509f5f8215b3f5e6
#
#
# Original source created by N. Bernaerts: https://github.com/NicolasBernaerts/debian-scripts/tree/master/asterisk
# modified per: https://jrklein.com/2015/08/17/asterisk-voicemail-transcription-via-ibm-bluemix-speech-to-text-api/
#
#
#!/usr/bin/env php
<?php
if (!isset($argv[2])){
echo "
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
*
* Script: lgaetz-dnd.php
*
* Latest version: https://gist.github.com/lgaetz/b350b9fa9ac18730150b387a1525aa4e
*
; 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
#!/usr/bin/php
<?php
// script requires a command - echo help and exit if arg1
if (!isset($argv[1])) {
echo "
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
*
* Script: lgaetz-tctoggle.php
*
@lgaetz
lgaetz / ariendpoints.php
Last active June 30, 2025 13:41 — forked from jfinstrom/ariendpoints.php
Dump endpoints with ARI and FreePBX
#!/usr/bin/env php
<?php
//test edit
if((@include '/etc/freepbx.conf') === false){
echo "Failed to include configuration\r\n";
return;
}
$ariuser = \FreePBX::Config()->get('FPBX_ARI_USER');
$aripass = \FreePBX::Config()->get('FPBX_ARI_PASSWORD');
$ari = new Pest('http://localhost:8088/ari');
@lgaetz
lgaetz / extensions_custom.conf
Last active May 22, 2025 20:36
Get FreePBX AMPUSER from Asterisk channel
; Asterisk dialplan sub that takes an Asterisk channel name and returns the matching FreePBX AMPUSER or null if no matching user
;
; License GNU/GPL3+
;
; Latest Version: https://gist.github.com/lgaetz/1d75bab3c975f0b6b54071a7c7c07d6d
;
; Usage: When writing asterisk dialplan for fpbx, reference the subroutine and pass the channel name as ARG1
; Channel name format follows something like PJSIP/4002-0000004f
; Example dialplan:
; exten => s,n,Gosub(get-AMPUSER-from-asterisk-channel,s,1(${DYNAMIC_WHO_ACTIVATED}))