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"}'