Skip to content

Instantly share code, notes, and snippets.

@ambiorixg12
ambiorixg12 / FreePBX Call foward API
Created December 26, 2020 22:13
FreePBX Call foward API
<?php
// show the fowarding value
//echo shell_exec("asterisk -x \" database show CF/$_GET[exten] \" ");
//update the fowarding value
//echo shell_exec("asterisk -x \" database put CF $_GET[exten] 13052311212 \" ");
@ambiorixg12
ambiorixg12 / originate command line
Created December 11, 2020 04:13
originate command line
<?php
$timeout=10;
$host="127.0.0.1";
$port=5038;
$src = preg_replace('/\s+/', '', $argv[1]);
$dst = preg_replace('/\s+/', '', $argv[2]);
$cid = preg_replace('/\s+/', '', $argv[3]);
$context1="from-internal";
$context2="from-internal";
$socket = fsockopen("$host",$port,$errno, $errstr, $timeout);
@ambiorixg12
ambiorixg12 / Twilio function json
Last active December 15, 2020 18:41
Twilio function json
exports.handler = function(context, event, callback) {
const axios = require('axios');
const Moment1 = require('moment-timezone');
const MomentRange = require('moment-range');
const moment = MomentRange.extendMoment(Moment1);
@ambiorixg12
ambiorixg12 / twilio voice to email trnascripted
Created November 24, 2020 23:36
twilio voice to email trnascripted
////// email function
//Initialize SendGrid Mail Client
const sgMail = require('@sendgrid/mail');
// Define Handler function required for all Twilio Functions
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
@ambiorixg12
ambiorixg12 / Twilio flow
Created November 19, 2020 21:47
Twilio flow
{
"description": "A New Flow",
"states": [
{
"name": "Trigger",
"type": "trigger",
"transitions": [
{
"event": "incomingMessage"
},
@ambiorixg12
ambiorixg12 / gist:ded1cd90d832b36d654cb3f58d843845
Last active November 19, 2020 02:48
Trigger a Twilio Studio Flow Execution via the REST API
Testa CODE to read webhook values
<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
foreach($_REQUEST as $key=>$value){
@ambiorixg12
ambiorixg12 / VICIDIAL carrier trunk
Last active October 5, 2020 04:11
VICIDIAL carrier trunk
[callcentric]
type=peer
disallow=all
allow=ulaw
allow=alaw
insecure=port,invite
directmedia=no
context=trunkinbound
qualify=yes
dtmfmode=rfc2833
@ambiorixg12
ambiorixg12 / twilio ivr time condition call recording
Last active October 20, 2020 02:09
twilio ivr time condition call recording
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
// getting time With timezone:
// In Functions/Configure, add NPM name: moment-timezone, version: 0.5.14
// Timezone function reference: https://momentjs.com/timezone/
//https://momentjscom.readthedocs.io/en/latest/moment/04-displaying/01-format/
let moment = require('moment-timezone');
//
// timezone needed for Daylight Saving Time adjustment
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
const command = event.Digits;
console.log( ` dtmf entered : ${event.Digits}`);
if ( `${event.Digits}` != 'undefined') {
@ambiorixg12
ambiorixg12 / replace and remove
Created August 12, 2020 21:10
replace and remove
removing particular character from a variable ( remove " )
echo '"18458254937"' | tr -d '"'
https://unix.stackexchange.com/questions/104881/remove-particular-characters-from-a-variable-using-bash