Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

martes, 2 de abril de 2024

custom transfer json

 [inbound_transf_exten]

exten=>_x.,1,Noop( DID ---${EXTEN}---  and   CALLERID ---${CALLERID(num)})

same=>n,agi(/var/www/html/call_transfer.php,${EXTEN},${CALLERID(num)})

same=>n,GotoIf($["${receiver}" = ""]?from-trunk,*788${EXTEN},1)

 same => n,NoOp(My action is: ${action})

 same => n,NoOp(My receiver is: ${receiver})

 same => n,NoOp(My duration is: ${duration})

 same => n,NoOp(My language is: ${lang})

 same => n,NoOp(My language is: ${cid_name})

 same => n,NoOp(My language is: ${cid_number})

 same => n,NoOp(My filename is: ${filename})

 same=>n,Set(CALLERID(all)=${cid_name}<${cid_number}>)

 same=>n,GotoIf($["${duration}" = ""]?from-internal,${receiver},1)

 ;same=>n,goto(from-internal,${receiver},1)

 same=>n,set(LIMIT_WARNING_FILE=${filename})

same=>n,Set(LIMIT_PLAYAUDIO_CALLER=yes)

same=>n,Set(LIMIT_PLAYAUDIO_CALLEE=yes)

same=>n,Set(LIMIT_TIMEOUT_FILE=)

same=>n,Dial(Local/${receiver}@from-internal,,L(${duration}:${start_sound}:))


 same=>n,hangup()


................


#!/usr/bin/php

<?php


// Check if command line arguments are provided

if ($argc < 3) {

    echo "Usage: php script.php [DID] [CID]\n";

    exit(1);

}


// Get DID and CID from command line arguments

$did = $argv[1];

$cid = $argv[2];


// Construct the URL

$url = "https://hub.servcenter.net/api/call_rules/rules/in/1/$did/$cid";


// Read JSON data from the URL

$jsonData = file_get_contents($url);


// Check if JSON data is successfully fetched

if ($jsonData === false) {

    echo "Error: Unable to fetch JSON data from URL.\n";

    exit(1);

}


// Decode the JSON data

$data = json_decode($jsonData, true);


// Check if JSON decoding was successful

if ($data !== null) {

    // Check if "rule" key exists and is an array

    if (isset($data['rule']) && is_array($data['rule'])) {

        // Loop through each key-value pair in the "rule" array

        foreach ($data['rule'] as $key => $value) {

     //echo  "$key=> $value\n";

        echo "SET VARIABLE $key \"$value\"\n";

        }

    } else {

echo "Error: 'rule' key not found or not an array in JSON data.\n";

    }

?>

{"total":2,"rule":{"action":"transfer","receiver":"1220","duration":false,"start_sound":false,"lang":null,"filename":null,"cid_name":"CB FRANCE","cid_number":"33-8140"}}

viernes, 16 de febrero de 2024

AMI custom chanspy

 $timeout = 10;

$host = "127.0.0.1";

$port = 5038;


// Check if required parameters are present and are numbers

if (

    is_numeric($_GET['local_extension']) &&

    is_numeric($_GET['a2b_extension']) &&

    isset($_GET['action'])

) {

    $local_extension = intval($_GET['local_extension']);

    $a2b_extension = intval($_GET['a2b_extension']);

    $action = preg_replace('/\s+/', '', $_GET['action']); // Remove spaces from action


    // Define username and secret

    $username = "admin";

    $secret = "6a16e190abd1qeee7d";


    $context_1 = "from-internal"; // Variable for out1

    $context_2 = "monitor"; // Variable for out2


    // Attempt to establish connection

    $socket = @fsockopen("$host", $port, $errno, $errstr, $timeout);

    if (!$socket) {

        echo "Error connecting to Asterisk Manager Interface: $errstr ($errno)";

        exit;

    }


    // Send AMI login command

    fputs($socket, "Action: Login\r\n");

    fputs($socket, "UserName: $username\r\n"); // Use username variable

    fputs($socket, "Secret: $secret\r\n\r\n"); // Use secret variable

    $wrets = fgets($socket, 128);


    // Send Originate command

    fputs($socket, "Action: Originate\r\n");

    fputs($socket, "Channel: Local/$local_extension@$context_1/n\r\n");

    fputs($socket, "Exten: $action\r\n");

    fputs($socket, "Context: $context_2\r\n");

    fputs($socket, "Priority: 1\r\n");

    fputs($socket, "CallerID: \r\n");

    fputs($socket, "Variable: __action=$action\r\n"); // Use sanitized action variable

    fputs($socket, "Variable: __a2b_extension=$a2b_extension\r\n"); // Add a2b_extension variable

    fputs($socket, "Async: yes\r\n\r\n");

    fputs($socket, "Action: Logoff\r\n\r\n");

    sleep(1);

    $wrets = fgets($socket, 128);

    echo $wrets;


    // Close the socket connection

    fclose($socket);

} else {

    echo "Missing or invalid parameters.";

}

?>

chanspy
;;;;;;;;;;;;;;

[monitor]
listen
exten => listen,1,Macro(user-callerid,)
exten => listen,n,Answer
exten => listen,n,NoCDR
exten => listen,n,Wait(1)
exten => listen,n,ChanSpy(sip/${EXTEN:3},q)
exten => listen,n,Hangup

whisper
exten => whisper,1,Macro(user-callerid,)
exten => whisper,n,Answer
exten => whisper,n,NoCDR
exten => whisper,n,Wait(1)
exten => whisper,n,ChanSpy(sip/${EXTEN:3},qw)
exten => whisper,n,Hangup

barge
exten => barge,1,Macro(user-callerid,)
exten => barge,n,Answer
exten => barge,n,NoCDR
exten => barge,n,Wait(1)
exten => barge,n,ChanSpy(sip/${EXTEN:3},qB)
exten => barge,n,Hangup

miércoles, 7 de febrero de 2024

CUSTOM_HEADER

 [vici]

exten => _X.,1,Noop(******making the call******)

exten => _91NXXNXXXXXX,1,AGI(agi-set_variables.agi)

exten => _91NXXNXXXXXX,n,NoOp(Customer phone number ${phone_number})

exten => _X.,n,Set(CUSTOM_HEADER_VALUE=${UNIQUEID})

exten => _X.,n,SIPAddHeader(X-Your-Custom-Header: ${CUSTOM_HEADER_VALUE})

exten => _X.,n,Dial(SIP/${trunk}/${EXTEN})


[a2b]

exten => _X.,1,Noop(******receiving call******)

exten => _X.,n,Noop(Custom SIP Header Value: ${SIP_HEADER(X-Your-Custom-Header)})

exten => _X.,n,Set(CDR(userfield)=${CUSTOM_HEADER_VALUE})


lunes, 1 de enero de 2024

ARI playback commands

 Start app:

Bash
wscat -c "ws://localhost:8088/ari/events?api_key=asterisk:asterisk&app=hello-world"

Start playing:

Bash
curl -v -u asterisk:asterisk -X POST "http://localhost:8088/ari/channels/1704160406.14/play?media=sound:/var/lib/asterisk/moh/macroform-robot_dity"

Stop:

Bash
curl -X DELETE -u asterisk:asterisk "http://localhost:8088/ari/playbacks/025e3fee-ddc8-4054-9d51-2f90622476de"

Pause:

Bash
curl -X POST -u asterisk:asterisk "http://localhost:8088/ari/playbacks/d7f46c57-db61-4eaf-8bc4-ecbe401176ce/control" \
-H "Content-Type: application/json" \
-d '{"operation": "pause"}'

domingo, 31 de diciembre de 2023

IAX2 trunk

[20026] ; server  accept registrations and calls


 deny=0.0.0.0/0.0.0.0

secret=af3c4078d

transfer=yes

context=from-internal

host=dynamic

type=friend

port=4569

qualify=yes

dial=IAX2/20026

accountcode=

permit=0.0.0.0/0.0.0.0

requirecalltoken=no

callerid=asreceived



[c2006]  ; client

username=20026
type=friend
secret=af3c4078d
requirecalltoken=no
qualify=no
host=10.0.0.45
encryption=no
context=from-trunk
auth=plaintext


register=>20026:af3c4078d@10.0.0.45

viernes, 22 de diciembre de 2023

setting file as asteirsk channel variables

 <?php

// Read the input string from a file

$inputString = file_get_contents('/home/voipessential/info_1.conf');


// Command line parameter

$searchValue = isset($argv[1]) ? $argv[1] : '';


// Explode the input string into an array based on the '-' delimiter

$lines = explode("\n", $inputString);

$dataArray = [];


// Iterate through each line and explode based on the '-' delimiter

foreach ($lines as $line) {

    $values = explode('-', $line);

    $dataArray[] = $values;

}


// Check if the search value is found in any array

foreach ($dataArray as $array) {

    if (in_array($searchValue, $array)) {

        // Set each value of the array as an Asterisk variable

        foreach ($array as $key => $value) {

            setAsteriskVariable($key, $value);

        }


        echo "Asterisk variables set for the array where the search value '$searchValue' is found.\n";

        break; // Stop after the first occurrence

    }

}


// Function to set Asterisk variable

function setAsteriskVariable($variableName, $variableValue) {

    // Set Asterisk variable

    echo "SET VARIABLE $variableName \"$variableValue\"\n";

}

?>


/home/voipessential/info_1.conf

59945-17542920051-600-14088772222
59955-19549063330-900-18003333330
57000-19546868344
57999-12159486620-400-18002314334
59867-17542912260
59868-18009860534



;;get  queue  time out and other values
same => n,AGI(/home/voipessential/set_variable.php,17542920051)
same => n,NoOp(Variable Value: ${1} ${2} ${3})

jueves, 2 de noviembre de 2023

custom ring group

 #!/usr/bin/php -q

<?php

set_time_limit(130);

require_once("/var/lib/asterisk/agi-bin/phpagi.php");

error_reporting(E_ALL);

$agi = new AGI();

$agi->answer();


$file = fopen("/var/www/html/custom_codes/devices.txt", "r");

$fileContent = '';

while (!feof($file)) {


 $line = fgets($file);



if (!empty($line)) {

  $dialstring .= "SIP/$line";

  }


$dialstring=trim($dialstring);




}

$agi->verbose("Dial($dialstring)");


$agi->exec('DIAL', "$dialstring"."SIP/dummy");


fclose($file);

?>



devices.txt


6122&

6146&

5101&

5102&



[custom_ring]

exten=>_x.,1,AGI(/var/www/html/custom_codes/ring_devices.php)

same=>n,hangup()