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, 27 de diciembre de 2016

custom lot

  1. [myucstom]
  2. exten=>_x.,1,Set(__outnum=${SHELL(php /var/www/html/file.php)})
  3. same => n,GotoIf($[${outnum}!=FALSE]?OK)
  4. same=>n,Playback(im-sorry)
  5. same=>n,hangup()
  6. same=>n(OK),Set(GLOBAL(caller)=${CHANNEL})
  7. same=>n,Set(__callercid=${CALLERID(num)})
  8. same=>n,Dial(Local/s@moh&Local/s@response)
  9. exten=>h,1,Set(GLOBAL(caller)=hangup)
  10.  
  11. [moh]
  12. exten=>s,1,Noop(///${caller}///)
  13. same=>n,Answer()
  14. same=n,Playback(/var/www/travel/sounds/welcome)
  15. same=>n,MusicOnHold(default)
  16. same=>n,Hangup()
  17.  
  18. [response]
  19.  exten=>s,1,Noop(///${caller}***${outnum}***)
  20. same=>n,System(/usr/sbin/asterisk -x "channel originate Local/${callercid}@cid extension s@hello")
  21.  
  22.  
  23. [cid]
  24. exten=>_x.,1,Set(CALLERID(num)=${EXTEN})
  25. same=>n,Set(__outnum=${SHELL(php /var/www/html/file.php)})
  26. same=>n,Set(GLOBAL(operator)=${CHANNEL})
  27. same=>n,Dial(SIP/602,5)
  28. ;same=>n,Dial(SIP/0011101306932454266@sbc.voxbeam.com,15)
  29. same => n,GotoIf($[${DIALSTATUS}="ANSWER"]?anws)
  30. same=>n,System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-8-1")
  31. same=>n,hangup()
  32. same=>n(answ),GotoIf($[$["${DIALSTATUS}"= "ANSWER"] && $["${op-in}"= "YES"]]?op-hangup-conf:op-no-conf)
  33. same=>n,Hangup()
  34. same=>n(op-hangup-conf),System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-14-2")
  35. same=>n,hangup()
  36. same=>n(op-no-conf),System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-10-2")
  37. same=>n,hangup()
  38.  
  39. [messages]
  40. exten=>s,1,Noop(do nothing)
  41. same=>n,hangup()
  42.  
  43. same=>n(message-8-1),Playback(/var/www/travel/sounds/8)
  44. same=>n,hangup()
  45. same=>n(message-10-1),Playback(/var/www/travel/sounds/10-1)
  46. same=>n,hangup()
  47.  
  48. same=>n(message-10-2),Playback(/var/www/travel/sounds/10-2)
  49. same=>n,hangup()
  50.  
  51. same=>n(message-14-1),Playback(/var/www/travel/sounds/14-1)
  52. same=>n,hangup()
  53.  
  54. same=>n(message-14-2),Playback(/var/www/travel/sounds/14-2)
  55. same=>n,hangup()
  56.  
  57. same=>n(message-11-2),Playback(/var/www/travel/sounds/11-2)
  58. same=>n,System(/usr/sbin/asterisk -x "channel redirect ${caller} hello,s,bridge")
  59.  
  60. [hello]
  61. exten=>s,1,Answer()
  62. same=>n(message),playback(/var/www/travel/sounds/messagetopo)
  63. same=>n,MixMonitor(/var/www/travel/${EXTEN}.wav)
  64. same=>n,Wait(5)
  65. same=>n(op-pre-message),Playback(/var/www/travel/sounds/11-2)
  66. same=>n,System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-11-2")
  67. same=>n,wait(5)
  68. same=>n(op-in),Set(GLOBAL(op-in)=YES)
  69. same=>n(bridge),Bridge(${caller})
  70. same=>n,Noop(Playing sound to  ${caller} / ${CHANNEL})
  71. same=>n,GotoIf($["${caller}"="${CHANNEL}"]?messages,s,message-14-2)
  72. ;same=>n,Playback(/var/www/travel/sounds/14-1)
  73. same=>n,Noop( caller var ${caller})
  74. same=>n,GotoIf($["${caller}"="hangup"]?messages,s,message-10-1)
  75. same=>n,Playback(goodbye)
  76. exten=>h,1,System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-10-2")
RAW Paste Data

sábado, 24 de diciembre de 2016

custom transf


[custom-trans]
include=>set-callflow
exten=>_6666,1,Answer()
same=>n,Set(status=${SHELL(cat /var/www/html/status.conf)})
same=>n,Noop(var status is ${status})
same=>n,GotoIf($["${status:0:1}"="1"]?DISPATCH_INIT2,s,1)
same=>n,goto(TRANSFER_AGENT2,s,1)
same=>n,hangup()

[set-callflow]
exten=>_1234,1,Answer()
same=>n,playback(/var/lib/asterisk/sounds/ivr-menu/menuivr)
same=>n,Set(status=${SHELL(cat /var/www/html/status.conf)})
same=>n,SayDigits(${status:0:1})
same=>n,read(newstatus,/var/lib/asterisk/sounds/ivr-menu/opcionmenu)
same=>n,ExecIf($["${newstatus}"="1"]?System(echo 1 >/var/www/html/status.conf))
same=>n,ExecIf($["${newstatus}"="0"]?System(echo 0 >/var/www/html/status.conf))
same=>n,playback(/var/lib/asterisk/sounds/ivr-menu/menuivr)
same=>n,SayDigits(${newstatus:0:1})
same=>n,Playback(goodbye)
same=>n,hangup()

martes, 20 de diciembre de 2016

Asterisk AMI event Filder

Since Asterisk 1.8, a new feature was added to the manager interface, the ability to use event filters to baclklist or whitelist manager events. If you use Asterisk 1.8 together with FOP2 you might want to set that up, so, fire up your editor and add the eventfilter lines to your manager.conf file:
  1. [fop2]
  2. secret = supersecret
  3. deny=0.0.0.0/0.0.0.0
  4. permit=127.0.0.1/255.255.255.0
  5. read = all
  6. write = all
  7. writetimeout = 1000
  8. eventfilter=!Event: RTCPSent
  9. eventfilter=!Event: RTCPReceived
  10. eventfilter=!Event: VarSet
  11. eventfilter=!Event: Cdr
  12. eventfilter=!Event: ExtensionStatus
  13. eventfilter=!Event: ChannelUpdate
The eventfilter will blacklist every event that is prefixed with ! and allow/whitelist everything else.
By the way, we can also add the writetimeout directive to avoid fop2 server from being disconnected when Asterisk gets mad.
source : http://forum.fop2.com/index.php/3722-make-fop2-snappier-using-ami-eventfilter

domingo, 11 de diciembre de 2016

Asterisk ARI Bridge

https://wiki.asterisk.org/wiki/display/AST/Introduction+to+ARI+and+Bridges

https://wiki.asterisk.org/wiki/display/AST/ARI+and+Bridges%3A+Holding+Bridges

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Bridges+REST+API

Asterisk Dial Limit

[inbound]
exten=>200,1,set(LIMIT_WARNING_FILE=beep)
same=>n,Set(LIMIT_PLAYAUDIO_CALLER=yes)
same=>n,Set(LIMIT_PLAYAUDIO_CALLEE=yes)
same=>n,Set(LIMIT_TIMEOUT_FILE=demo-thanks)
same=>n,Dial(Local/200@mymusic,,L(60000:30000:10000))


[mymusic]
exten=>200,1,Answer()
same=>n,MusicOnHold(default)

Limit call to 60 seconds, play a beep every 10 seconds, and at the end play the  asterisk-demo thanks message to caller and  callee

viernes, 9 de diciembre de 2016

mult event ban

<?php


$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
      if (!$socket){
        echo "$errstr ($errno)\n";
        }else{
            fputs($socket, "Action: Login\r\n");
            fputs($socket, "UserName: admin\r\n");
            fputs($socket, "Secret: mypass456\r\n\r\n");
            fputs($socket, "Action: WaitEvent\r\n");
            fputs($socket, "Action: Logoff\r\n\r\n");

 while(!feof($socket)){
  $result=fread($socket,5000);
$event=array("InvalidAccountID","InvalidPassword");
if (preg_match("/\b$event[0]\b/i", $result,$match) || preg_match("/\b$event[1]\b/i", $result,$match)){


$result=explode("\n",$result);
//foreach($result as $key=>$value){
//echo "$key : $value\n";
$ip=$result[9];

$ip=explode("/",$ip);


echo "$ip[2]\n";
system("iptables -A INPUT -s $ip[2] -j DROP");

//}

}
}
}
fclose($socket);


?>

 nohup php ami_guard.php >> ban.txt &

AMI banning IP

<?php


$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
      if (!$socket){
        echo "$errstr ($errno)\n";
        }else{
            fputs($socket, "Action: Login\r\n");
            fputs($socket, "UserName: admin\r\n");
            fputs($socket, "Secret: mypass456\r\n\r\n");
            fputs($socket, "Action: WaitEvent\r\n");
            fputs($socket, "Action: Logoff\r\n\r\n");

 while(!feof($socket)){
  $result=fread($socket,5000);

if (preg_match("/\b$argv[1]\b/i", $result,$match)){

//echo $result;
$result=explode("\n",$result);
foreach($result as $key=>$value){
//echo "$key : $value\n";
$ip=$result[9];

$ip=explode("/",$ip);


echo "$ip[2]\n";
system("iptables -A INPUT -s $ip[2] -j DROP");
}

}
}
}
fclose($socket);


?>


php ami_guard.php InvalidAccountID


      nohup php ami_guard.php InvalidAccountID >> ban.txt &


AMI event catcher

<?php


$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
      if (!$socket){
        echo "$errstr ($errno)\n";
        }else{
            fputs($socket, "Action: Login\r\n");
            fputs($socket, "UserName: admin\r\n");
            fputs($socket, "Secret: mypass456\r\n\r\n");
            fputs($socket, "Action: WaitEvent\r\n");
            fputs($socket, "Action: Logoff\r\n\r\n");

 while(!feof($socket)){
  $result=fread($socket,5000);

if (preg_match("/\b$argv[1]\b/i", $result,$match)){

echo $result;
}
}
}
fclose($socket);


?>

catch event  php ami.php Newchannel

runt this command php ami.php Newchannel



Array vesion



/****************************/

<?php


$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
      if (!$socket){
        echo "$errstr ($errno)\n";
        }else{
            fputs($socket, "Action: Login\r\n");
            fputs($socket, "UserName: admin\r\n");
            fputs($socket, "Secret: mypass456\r\n\r\n");
            fputs($socket, "Action: WaitEvent\r\n");
            fputs($socket, "Action: Logoff\r\n\r\n");

 while(!feof($socket)){
  $result=fread($socket,5000);

if (preg_match("/\b$argv[1]\b/i", $result,$match)){

//echo $result;
$result=explode("\n",$result);
foreach($result as $key=>$value){
echo "$key : $value\n";
}

}
}
}
fclose($socket);


?>






root@asterisk-dominicana:~# php ami.php Newchannel
0 : Event: Newchannel
1 : Privilege: call,all
2 : Channel: SIP/102-0000abd1
3 : ChannelState: 0
4 : ChannelStateDesc: Down
5 : CallerIDNum: 102
6 : CallerIDName: <unknown>
7 : ConnectedLineNum: <unknown>
8 : ConnectedLineName: <unknown>
9 : Language: en
10 : AccountCode:
11 : Context: home
12 : Exten: 13052362323
13 : Priority: 1
14 : Uniqueid: 1481351003.64411
15 : Linkedid: 1481351003.64411
16 :
17 :
0 : Event: Newchannel
1 : Privilege: call,all
2 : Channel: SIP/400-0000abd2
3 : ChannelState: 0
4 : ChannelStateDesc: Down
5 : CallerIDNum: <unknown>
6 : CallerIDName: phone
7 : ConnectedLineNum: <unknown>
8 : ConnectedLineName: <unknown>
9 : Language: en
10 : AccountCode:
11 : Context: pstn
12 : Exten: s
13 : Priority: 1
14 : Uniqueid: 1481351003.64412
15 : Linkedid: 1481351003.64411
16 :
17 :

nohup php event_catch.php Newchannel >> even.txt 

BASIC PHP AMI connection

<?php


$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
      if (!$socket){
        echo "$errstr ($errno)\n";
        }else{
            fputs($socket, "Action: Login\r\n");
            fputs($socket, "UserName: admin\r\n");
            fputs($socket, "Secret: mypass456\r\n\r\n");
            fputs($socket, "Action: WaitEvent\r\n");
            fputs($socket, "Action: Logoff\r\n\r\n");

 while(!feof($socket)){

  $result=fread($socket,5000);

echo $result;

}
}
fclose($socket);


?>

miércoles, 16 de noviembre de 2016

Global Variables Basics


Saltar al final de los metadatos
Ir al inicio de los metadatos
Global variables are variables that don't live on one particular channel — they pertain to all calls on the system. They have global scope. There are two ways to set a global variable. The first is to declare the variable in the [globals] section of extensions.conf, like this:
[globals]
MYGLOBALVAR=somevalue
You can also set global variables from dialplan logic using the GLOBAL() dialplan function along with the Set() application. Simply use the syntax:
exten=>6124,1,Set(GLOBAL(MYGLOBALVAR)=somevalue)
To retrieve the value of a global channel variable, use the same syntax as you would if you were retrieving the value of a channel variable.

martes, 15 de noviembre de 2016

twilio sms using curl

 curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/AC4cd51364f73a254df228050e9788f90c1a/Messages.json' \
> --data-urlencode 'To=18097143489'  \
> --data-urlencode 'From=+18779990230'  \
> --data-urlencode 'Body=Just testing curl' \
> -u AC4cd51364f73a254df228050e9788f90c:c63c01506d9dd94b788a170b3208f11f
{"sid": "SM41aabac2c3934a5fbcf7446626d4dcf5", "date_created": "Wed, 16 Nov 2016 07:55:22 +0000", "date_updated": "Wed, 16 Nov 2016 07:55:22 +0000", "date_sent": null, "account_sid": "AC4cd51364f73a254df228050e9788f90c", "to": "+18097143489", "from": "+18779990230", "messaging_service_sid": null, "body": "Just testing curl", "status": "queued", "num_segments": "1", "num_media": "0", "direction": "outbound-api", "api_version": "2010-04-01", "price": null, "price_unit": "USD", "error_code": null, "error_message": null, "uri": "/2010-04-01/Accounts/AC4cd51364f73a254df228050e9788f90c/Messages/SM41aabac2c3934a5fbcf7446626d4dcf5.json", "subresource_uris": {"media": "/2010-04-01/Accounts/AC4cd51364f73a254df228050e9788f90c/Messages/SM41aabac2c3934a5fbcf7446626d4dcf5/Media.json"}}

https://www.twilio.com/console/dev-tools/api-explorer/sms/sms-mms-create

getting twilio message properties

<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once './twilio-php-master/Twilio/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "AC4cd51364f734dtt4df228050e9788f90c";
$token = "c63c01506d9dd94b5sww788a170b3208f11f";
$client = new Client($sid, $token);

// Loop over the list of smss and echo a property for each one
foreach ($client->messages->read() as $sms) {
    echo $sms->to." ".$sms->status." ".$sms->sid."\n";

$sms = $client
   ->messages($sms->sid)
->fetch();

echo $sms->body."\n";

}
?>

php list-all.php
+18097143489 delivered SM1281e9eee50644038d2d2e4969b931a8
Testing mms
+18097143489 delivered MM4fe9abd1cee742fda7657db7e434764b
Testing mms
http://m.twil.io/dShvo7J
+18097143489 delivered MMa323f084842142afad38a6b85949f10a
Testing mms
http://m.twil.io/3JuxmXv
+14012196176 delivered SMd2f5c77178ae46a1be9e0eabb1305860
We Love Twilo
+18097143489 delivered SM77720d7889ae442b94a3b697b576417f
I love twilio!
+18097143489 delivered SM1c8aa8d76d2d4c648003bf8a367100a0
I
+18097143489 delivered SM90e23c23c0424a00abca30473876cf80
Hey testing Twilio sms service!
+18097143489 delivered SMbbc077ff378f49ad8eed166237d28eeb
Hey Jenny! Good luck on the bar exam!


domingo, 13 de noviembre de 2016

Twilio sms

<?php
// Require the bundled autoload file - the path may need to change
// based on where you downloaded and unzipped the SDK
require __DIR__ . '/twilio-php-master/Twilio/autoload.php';

// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;

// Your Account SID and Auth Token from twilio.com/console
$sid = 'AC4cd51364f73aw154df228050ex2933';
$token = 'c63c01506d9ddxw4b788a17ssxd11f';
$client = new Client($sid, $token);

// Use the client to do fun stuff like send text messages!
$client->messages->create(
    // the number you'd like to send the message to
    "+$argv[1]",
    array(
        // A Twilio phone number you purchased at twilio.com/console
        "from" => "+14017953076 ",
        // the body of the text message you'd like to send
        'body' => "$argv[2]"
    )
);
//https://www.twilio.com/docs/libraries/php
?>


1)  wget https://github.com/twilio/twilio-php/archive/master.zip

2)unzip  mas*

3)cat ./twilio-php-master/Twilio/autoload.php


php sms.php 18097143423  'I love twilio!'


https://www.twilio.com/docs/libraries/php

https://www.twilio.com/docs/quickstart/php/sms/sending-via-rest#sending-mms-via-rest

https://support.twilio.com/hc/en-us/articles/223181808-Restricted-SMS-message-types-using-Twilio

https://support.twilio.com/hc/en-us/articles/223133967-Changing-the-sender-ID-for-sending-SMS-messages

https://support.twilio.com/hc/en-us/articles/223181348-Getting-started-with-Alphanumeric-Sender-ID

https://www.twilio.com/docs/api/twiml/sms/your_response

https://www.twilio.com/docs/api/rest/sms

https://www.twilio.com/docs/api/rest/sending-messages

jueves, 10 de noviembre de 2016

IP monitor

#!/usr/bin/php -q

<?php

$sip_peers=shell_exec("/usr/sbin/asterisk -x \" sip show peers\" | awk '{print $2}' | grep -v Unspecified | grep -v sip | grep -v Host");

$ip=explode("\n",$sip_peers);

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

$url=file_get_contents("http://ipinfo.io/$value");

$url=json_decode($url, true);

$whitelist=array("71.41.210.190","66.241.99.90","64.2.142.187","104.238.138.237","127.0.0.1");

/* if($url['country']!="US");  use this if statement if want to filter by IP*/

if(!in_array($url['ip'],$whitelist)) {

if(!isset($url['ip'])) {
echo " too many request sent";
exit();
}

echo  $url['country']." RED ALERT  UNKNOWN IP ". $url['ip']."\n";

$body="Unauthorized peer   with the IP ". $url['ip'];

$headers = 'From: Asterisk Dominicana <ambiorixg12@asterisk-dominicana.com>' . "\r\n";

$headers  .= 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail("ambiorixg12@gmail.com"," Asterisk  Alert",$body,$headers);

$remoteip=$url['ip'];
system("/sbin/iptables -A INPUT -s $remoteip -j DROP");

continue;
}
echo $url['ip']." ".$url['country']."\n";

}





crontab -e
*/5 * * * * /usr/bin/php /root/ip_monitor.php >> /root/ip-results.txt 2>> /root/ip-errror.txt

domingo, 6 de noviembre de 2016

Local channel and hold

[myucstom]
exten=>_x.,1,Set(__outnum=${SHELL(php /var/www/file.php)})
same => n,GotoIf($[${outnum}!=FALSE]?OK)
same=>n,Playback(im-sorry)
same=>n,hangup()
same=>n(OK),Set(__caller=${CHANNEL})
same=>n,Set(__caller_two=${EXTEN})
same=>n,Set(__callercid=${CALLERID(num)})
same=>n,Dial(Local/s@moh&Local/s@response)
same=>n,Playback(/var/www/travel/sounds/goodbye)

[moh]
exten=>s,1,Noop(///${caller}///)
same=>n,Answer()
same=n,Playback(/var/www/travel/sounds/welcome)
same=>n,MusicOnHold(default)
same=>n,Hangup()

[response]
 exten=>s,1,Noop(///${caller}***${outnum}***)

same=>n,System(/usr/sbin/asterisk -x "channel originate Local/${callercid}@cid extension ${caller}@hello")

[cid]
exten=>_x.,1,Set(CALLERID(num)=${EXTEN})
same=>n,Set(__outnum=${SHELL(php /var/www/file.php)})
same=>n,Dial(SIP/601)
;same=>n,Dial(SIP/0011101306932454266@sbc.voxbeam.com)


[hello]
exten=>_.,1,Answer()
same=>n,Noop(*** ${EXTEN} ***${outnum}** )
same=>n(message),playback(/var/www/travel/sounds/messagetopo)
same=>n,MixMonitor(/var/www/travel/${EXTEN}.wav)
same=>n,Bridge(${EXTEN})
same=>n,Playback(/var/www/travel/sounds/goodbye)



El  cliente  se queda en espera escuchando musica,  luego el agente escucha el mensaje de la llamada del cliente  y luego se unen en unica llamada

jueves, 27 de octubre de 2016

custom parking lot

  1. exten=>_2XXX,1,Answer()
    same=>n,Set(PARKINGEXTEN=${EXTEN:2})
    same=>n,park()
    same=>n,Set(CALLERID(name)=Failed Parking Lot)
    same=>n,Noop( checking var ${BLINDTRANSFER:0:7})
    same=>n,Set(ALERTINFOA=\;info=Ring2)
    same=>n,SipAddHeader(${ALERTINFOA}))
    same=>n,Dial(${BLINDTRANSFER:0:7})
IF you blind transfer to  the  specific parking lot it  will park the customer on that specific lot, if lot is busy, it will call   the extension who transferred the call


Note this will park spaces  parkpos => 701-720 , using the default Parking Lot created on res_parking.conf, if you want use spefic slot you will need create you parking lot on res_parking.conf and then include the contextt

miércoles, 19 de octubre de 2016

Autoanswer and Server side auto answer.

Zoiper 3 Biz supports both Autoanswer and Server side auto answer.

Autoanswer is a BIZ feature, It is not available for the free version of Zoiper.

Enabling  Auto answer in Zoiper 3:
Open the Settings menu and select Automation


A new window will open. Configure it by your own preference.