Skip to content

Instantly share code, notes, and snippets.

@lgaetz
Created November 24, 2023 16:40
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/6ff9aeff59de40df5755c52d85a65c9b to your computer and use it in GitHub Desktop.
Save lgaetz/6ff9aeff59de40df5755c52d85a65c9b to your computer and use it in GitHub Desktop.
Local PHP script for originating a call from local extension to another number
<?php
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
*
* Script: lgaetz-click2call.php
*
* Latest version: https://gist.github.com/lgaetz/6ff9aeff59de40df5755c52d85a65c9b
*
* Usage: Scipt to list/toggle/set FreePBX Call Flow Controls. Developed for FreePBX 16
*
* License: GNU/GPL3+
*
* History:
* 2023-11-24 Black Friday first commit
*
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
include_once('/etc/freepbx.conf');
global $astman; // phpagi class
// Construct an array for originating a call to local extension 7004 that bridges to 7002 when answered
$dial = array();
$dial['Channel'] = "local/7004@originate-skipvm"; // built in fpbx context to ensure call does not go to vm
// $dial['Channel'] = "local/*807004@originate-skipvm"; // prefix dialed digits with intercom prefix to auto answer first leg
$dial['Context'] = "from-internal";
$dial['Exten'] = "7002";
$dial['Priority'] = "1";
$dial['Async'] = 'no';
$dial['Timeout'] = "5000"; // how long to wait for initial answer in ms
$dial['CallerID'] = '"Click-To-Dial" <Click-To-Dial>'; // Caller ID for first leg of call. Enabling PAI connected line will allow the CID to be updated when the call is bridged
// To set variables as part of the, you can do it in this format for each
$dial['Variable']['var_name_1'] = 'var_value_1';
$dial['Variable']['var_name_2'] = 'var_value_2';
// using $astman class from bootstrap, originate the call
$astman->Originate($dial);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment