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, 18 de julio de 2017

sábado, 15 de julio de 2017

FreePBX custom extension




[from-internal-custom]
exten=>_100,1,Answer()
same=>n,Playback(hello-world)

sábado, 8 de julio de 2017

Google Speech API

https://cloud.google.com/speech/docs/languages
https://cloud.google.com/speech/docs/basics
https://github.com/GoogleCloudPlatform/php-docs-samples/blob/master/speech/quickstart/quickstart.php
https://cloud.google.com/speech/docs/getting-started
https://cloud.google.com/speech/docs/basics
https://cloud.google.com/speech/docs/reference/libraries#client-libraries-usage-php

lunes, 5 de junio de 2017

freepx asterisk service


Saltar al final de los metadatos
Ir al inicio de los metadatos
As most distributions have moved to systemd, here's an example startup script that you may customize for your installation.
This has been tested to work on CentOS 7.
Contents of /etc/systemd/system/freepbx.service
[Unit]
Description=FreePBX VoIP Server
After=mariadb.service
 
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start -q
ExecStop=/usr/sbin/fwconsole stop -q
 
[Install]
WantedBy=multi-user.target
  
From there you can enable it so it starts automatically
Note that on Debian 8.1, you need to use After=mysql.service, not After=mariadb.service. 
[root@firewall ~]# systemctl enable freepbx.service
ln -s '/etc/systemd/system/freepbx.service' '/etc/systemd/system/multi-user.target.wants/freepbx.service'
[root@firewall ~]#
And then start it yourself if you haven't already
[root@firewall ~]# systemctl start freepbx
[root@firewall ~]#
You can check the output of the startup with the 'systemctl status' command
[root@firewall ~]# systemctl status -l freepbx.service
freepbx.service - FreePBX VoIP Server
   Loaded: loaded (/etc/systemd/system/freepbx.service; enabled)
   Active: active (exited) since Mon 2015-08-17 09:20:09 AEST; 52s ago
  Process: 5020 ExecStart=/usr/sbin/fwconsole start (code=exited, status=0/SUCCESS)
 Main PID: 5020 (code=exited, status=0/SUCCESS)
Aug 17 09:20:06 firewall.xrobau.com fwconsole[5020]: Running Sysadmin Hooks
Aug 17 09:20:06 firewall.xrobau.com fwconsole[5020]: Starting Asterisk...
Aug 17 09:20:06 firewall.xrobau.com fwconsole[5020]: 0/100 [>---------------------------]   0%
Aug 17 09:20:07 firewall.xrobau.com fwconsole[5020]: 33/100 [=========>------------------]  33%
Aug 17 09:20:08 firewall.xrobau.com fwconsole[5020]: 66/100 [==================>---------]  66%
Aug 17 09:20:09 firewall.xrobau.com fwconsole[5020]: 99/100 [===========================>]  99%
Aug 17 09:20:09 firewall.xrobau.com fwconsole[5020]: 100/100 [============================] 100%
Aug 17 09:20:09 firewall.xrobau.com fwconsole[5020]: Asterisk Started on  5523
Aug 17 09:20:09 firewall.xrobau.com fwconsole[5020]: Running Post-Asterisk Scripts
Aug 17 09:20:09 firewall.xrobau.com systemd[1]: Started FreePBX VoIP Server.
[root@firewall ~]#

domingo, 28 de mayo de 2017

Creating and Manipulating Channels from the CLI

Ir al inicio de los metadatos
Here we'll mention a few commands that allow you to create or manipulate channels at the CLI during runtime.

channel request hangup

Provided by the core, this command simply allows you to request that a specified channel or all channels be hungup.
Usage: channel request hangup <channel>|<all>
       Request that a channel be hung up. The hangup takes effect
       the next time the driver reads or writes from the channel.
       If 'all' is specified instead of a channel name, all channels
       will see the hangup request.
An example:
newtonr-laptop*CLI> core show channels
Channel              Location             State   Application(Data)             
SIP/6001-00000001    (None)               Up      Playback(demo-congrats)       
1 active channel

newtonr-laptop*CLI> channel request hangup SIP/6001-00000001 
Requested Hangup on channel 'SIP/6001-00000001'
[May  2 09:51:19] WARNING[7045][C-00000001]: app_playback.c:493 playback_exec: Playback failed on SIP/6001-00000001 for demo-congrats
Here I made a call to an extension calling Playback, then from the CLI I requested that the established channel be hung up. You can see that it hung up in the middle of playing a sound file, so that sound file fails to continue playing.

channel originate

Provided by res_clioriginate.so, this command allows you to create a new channel and have it connect to either a dialplan extension or a specific application.
  There are two ways to use this command. A call can be originated between a
channel and a specific application, or between a channel and an extension in
the dialplan. This is similar to call files or the manager originate action.
Calls originated with this command are given a timeout of 30 seconds.
Usage1: channel originate <tech/data> application <appname> [appdata]
  This will originate a call between the specified channel tech/data and the
given application. Arguments to the application are optional. If the given
arguments to the application include spaces, all of the arguments to the
application need to be placed in quotation marks.
Usage2: channel originate <tech/data> extension [exten@][context]
  This will originate a call between the specified channel tech/data and the
given extension. If no context is specified, the 'default' context will be
used. If no extension is given, the 's' extension will be used.
An example:
newtonr-laptop*CLI> channel originate SIP/6001 extension 9999@somecontext
  == Using SIP RTP CoS mark 5
    -- Called 6001
    -- SIP/6001-00000004 is ringing
       > 0x7f0828067710 -- Probation passed - setting RTP source address to 10.24.18.16:4046
    -- SIP/6001-00000004 answered
    -- Executing [9999@somecontext:1] VoiceMailMain("SIP/6001-00000004", "") in new stack
    -- <SIP/6001-00000004> Playing 'vm-login.gsm' (language 'en')
       > 0x7f0828067710 -- Probation passed - setting RTP source address to 10.24.18.16:4046
We originated a call to the chan_sip peer 6001 in this case. The extension parameter tells it what extension to connect that channel to once the channel answers. In this case we connect it to an extension calling VoiceMailMain.

channel redirect

Provided by res_clioriginate.so, this command allows you to redirect an existing channel to a dialplan extension.
Usage: channel redirect <channel> <[[context,]exten,]priority>
    Redirect an active channel to a specified extension.
An example:
    -- Executing [100@from-internal:1] Playback("SIP/6001-00000005", "demo-congrats") in new stack
       > 0x7f07ec03e560 -- Probation passed - setting RTP source address to 10.24.18.16:4048
    -- <SIP/6001-00000005> Playing 'demo-congrats.gsm' (language 'en')
newtonr-laptop*CLI> channel redirect SIP/6001-00000005 somecontext,9999,1
Channel 'SIP/6001-00000005' successfully redirected to somecontext,9999,1
[May  2 09:56:28] WARNING[7056][C-00000005]: app_playback.c:493 playback_exec: Playback failed on SIP/6001-00000005 for demo-congrats
    -- Executing [9999@somecontext:1] VoiceMailMain("SIP/6001-00000005", "") in new stack
    -- <SIP/6001-00000005> Playing 'vm-login.gsm' (language 'en')
Here we make a call from SIP/6001 to a 100@from-internal, which results in a call to Playback. After the call is established, we issue a 'channel redirect' to redirect that channel to the extension 9999 in the context 'somecontext'. It is immediately placed into that extension and we hear the VoicemailMain prompt.

miércoles, 24 de mayo de 2017

writing data fron Asterisk to a file using php

<?php
$file="/etc/asterisk/data.txt";
$data=$argv[1]."\n";
$data.="$argv[2]";
file_put_contents("$file", $data,FILE_APPEND);
?>


exten=>_1011,1,Noop()
same=>n,system(php /root/script_write.php ${CHANNEL} ${UNIQUEID})

jueves, 11 de mayo de 2017

fix freepbx session permision

This is is fixed   with  a fwconsole chown   amportal chown


[2017-May-11 11:16:39] [PHP-WARNING] (Unknown:0) - Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session)
[2017-May-11 11:18:02] [PHP-WARNING] (Unknown:0) - Unknown: open(/var/lib/php/session/sess_58fcq9tj2015tvkin9lqo1s6m3, O_RDWR) failed: Permission denied (13)
[2017-May-11 11:18:02] [PHP-WARNING] (Unknown:0) - Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session)
[2017-May-11 11:18:06] [WARNING] (libraries/modulefunctions.legacy.php:7) - Depreciated Function module_getinfo detected in /var/www/html/admin/modules/cxpanel/functions.inc.php on line 52
[2017-May-11 11:18:06] [WARNING] (libraries/modulefunctions.legacy.php:7) - Depreciated Function module_getinfo detected in /var/www/html/admin/modules/cxpanel/functions.inc.php on line 71
[2017-May-11 11:18:06] [PHP-NOTICE] (/var/www/html/admin/modules/sysadmin/functions.inc/general.php:41) - Undefined index: deploymentid
[2017-May-11 11:18:06] [PHP-WARNING] (Unknown:0) - Unknown: open(/var/lib/php/session/sess_58fcq9tj2015tvkin9lqo1s6m3, O_RDWR) failed: Permission denied (13)
[2017-May-11 11:18:06] [PHP-WARNING] (Unknown:0) - Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session)
[2017-May-11 11:18:12] [PHP-WARNING] (Unknown:0) - Unknown: open(/var/lib/php/session/sess_58fcq9tj2015tvkin9lqo1s6m3, O_RDWR) failed: Permission denied (13)
[2017-May-11 11:18:12] [PHP-WARNING] (Unknown:0) - Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session)

jueves, 13 de abril de 2017

CID Lookup

[from-cnam]
exten=>_x.,1,Noop( **${CALLERID(name)}**  **${CALLERID(num)}**)
;same=>n,GotoIf($["${CALLERID(name)}" != "Unknown"]?valid)
same=>n,GotoIf($["${CALLERID(name)}" != ""]?valid)
same=>n,Set(name=${SHELL(php /var/www/html/cname/cid.php ${CALLERID(num)})})
same=>n,Set(CALLERID(name)=${name})
same=>n(valid),Goto(from-trunk,${EXTEN},1)




<?php
error_reporting(0);
$url=file_get_contents("http://api.everyoneapi.com/v1/phone/$argv[1]?account_sid=AC95f600f22fe04ab9a74a501aed72ff73&auth_token=AU926f2e2d89124cbdaa92f76b1ab7ff27&pretty=true&data=name");

$url=json_decode($url, true);


//print_r($url);

//print_r($url[data][expanded_name]);



if(!$url['data']['expanded_name']) {
echo "Unknow Caller";
exit();

}
foreach($url['data']['expanded_name'] as $key=>$value){
}
$cname=$url['data']['expanded_name']['first'];
$cname.=" ".$url['data']['expanded_name']['last'];

echo $cname;

exit();

?>

viernes, 7 de abril de 2017

${EXTEN} MANIPULATION

The ${EXTEN} variable properly has the syntax ${EXTEN:x:y}, where x is the starting position and y is the number of digits to return. Given the following dial string:
94169671111
we can extract the following digit strings using the ${EXTEN:x:y} construct:
  • ${EXTEN:1:3} would contain 416
  • ${EXTEN:4:7} would contain 9671111
  • ${EXTEN:-4:4} would start four digits from the end and return four digits, giving us 1111
  • ${EXTEN:2:-4} would start two digits in and exclude the last four digits, giving us 16967
  • ${EXTEN:-6:-4} would start six digits from the end and exclude the last four digits, giving us 67
  • ${EXTEN:1} would give us everything after the first digit, or 4169671111 (if the number of digits to return is left blank, it will return the entire remaining string)
This is a very powerful construct, but most of these variations are not very common in normal use. For the most part, you will be using ${EXTEN} (or perhaps ${EXTEN:1} if you need to strip off an external access code).

miércoles, 15 de marzo de 2017

Originate cutom foward

[customtransf]
include=>from-internal

exten=>_XXXXXXXXXX,1,Noop()
same=>n,Set(GLOBAL(announcement)=/var/lib/asterisk/sounds/en/demo-thanks)
same=>n,Set(transf_num=${SHELL(cat /etc/asterisk/foward.list | egrep ${CALLERID(num)} | awk -F - '{print $1}')})
same=>n,Set(GLOBAL(transf)=${transf_num:0:3})
same=>n,Set(GLOBAL(dest)=${EXTEN})
same=>n,originate(Local/${transf}@customtransf_dial,exten,from-internal,${dest},1)
same=>n,Hangup()



[customtransf_dial]
exten=>_x.,1,Set(CALLERID(num)=${dest})
same=>n,Dial(SIP/${transf},,A(${announcement}))
same=>n,Hangup()


lunes, 27 de febrero de 2017

CDR centos 6.5 Config


/etc/odbc.ini



[asterisk-mysql]
Description           = MySQL connection to 'asterisk' database
Driver                = MySQL
Database              = asteriskcdrdb
Server                = localhost
UserName              = root
Password              = 7891
Port                  = 3306
Socket                = /var/lib/mysql/mysql.sock






/etc/odbcinst.ini



# Example driver definitions

# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description     = ODBC for PostgreSQL
Driver          = /usr/lib/psqlodbc.so
Setup           = /usr/lib/libodbcpsqlS.so
Driver64        = /usr/lib64/psqlodbc.so
Setup64         = /usr/lib64/libodbcpsqlS.so
FileUsage       = 1


# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description     = ODBC for MySQL
Driver          = /usr/lib/libmyodbc5.so
Setup           = /usr/lib/libodbcmyS.so
Driver64        = /usr/lib64/libmyodbc5.so
Setup64         = /usr/lib64/libodbcmyS.so
FileUsage       = 1




/etc/asterisk/res_odbc_custom.conf

[asterisk-mysql]
enabled => yes
dsn => asterisk-mysql
username => root
password => 7891
pre-connect => yes




/etc/asterisk/cdr_adaptive_odbc.conf



[asterisk-mysql]
connection=asterisk-mysql
table=cdr
alias start => calldate




Load  on asterisk

module reload res_odbc.so

Module 'res_odbc.so' reloaded successfully.
    -- Reloading module 'res_odbc.so' (ODBC resource)
  == Parsing '/etc/asterisk/res_odbc.conf': Found
  == Parsing '/etc/asterisk/res_odbc_custom.conf': Found
  == Parsing '/etc/asterisk/res_odbc_additional.conf': Found
[2015-09-04 14:48:27] NOTICE[10623]: res_odbc.c:1528 odbc_obj_connect: Connecting asterisk-mysql
[2015-09-04 14:48:27] NOTICE[10623]: res_odbc.c:1567 odbc_obj_connect: res_odbc: Connected to asterisk-mysql [asterisk-mysql]
[2015-09-04 14:48:27] NOTICE[10623]: res_odbc.c:923 load_odbc_config: Registered ODBC class 'asterisk-mysql' dsn->[asterisk-mysql]
[2015-09-04 14:48:27] NOTICE[10623]: res_odbc.c:1528 odbc_obj_connect: Connecting asteriskcdrdb
[2015-09-04 14:48:27] WARNING[10623]: res_odbc.c:1560 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
[2015-09-04 14:48:27] WARNING[10623]: res_odbc.c:1370 _ast_odbc_request_obj2: Failed to connect to asteriskcdrdb
[2015-09-04 14:48:27] NOTICE[10623]: res_odbc.c:923 load_odbc_config: Registered ODBC class 'asteriskcdrdb' dsn->[MySQL-asteriskcdrdb]
ibx2*CLI>






ibx2*CLI> module reload cdr_adaptive_odbc.so


Module 'cdr_adaptive_odbc.so' reloaded successfully.
    -- Reloading module 'cdr_adaptive_odbc.so' (Adaptive ODBC CDR backend)
  == Parsing '/etc/asterisk/cdr_adaptive_odbc.conf': Found
    -- Found adaptive CDR table cdr@asterisk-mysql.
    -- Found alias start for column calldate in cdr@asterisk-mysql
       > Found calldate column with type 93 with len 19, octetlen 19, and numlen (0,10)
       > Found clid column with type 12 with len 80, octetlen 80, and numlen (0,0)
       > Found src column with type 12 with len 80, octetlen 80, and numlen (0,0)
       > Found dst column with type 12 with len 80, octetlen 80, and numlen (0,0)
       > Found dcontext column with type 12 with len 80, octetlen 80, and numlen (0,0)
       > Found channel column with type 12 with len 80, octetlen 80, and numlen (0,0)
       > Found dstchannel column with type 12 with len 80, octetlen 80, and numlen (0,0)
       > Found lastapp column with type 12 with len 80, octetlen 80, and numlen (0,0)
       > Found lastdata column with type 12 with len 80, octetlen 80, and numlen (0,0)
       > Found duration column with type 4 with len 10, octetlen 10, and numlen (0,10)
       > Found billsec column with type 4 with len 10, octetlen 10, and numlen (0,10)
       > Found disposition column with type 12 with len 45, octetlen 45, and numlen (0,0)
       > Found amaflags column with type 4 with len 10, octetlen 10, and numlen (0,10)
       > Found accountcode column with type 12 with len 20, octetlen 20, and numlen (0,0)
       > Found uniqueid column with type 12 with len 32, octetlen 32, and numlen (0,0)
       > Found userfield column with type 12 with len 255, octetlen 255, and numlen (0,0)
       > Found did column with type 12 with len 50, octetlen 50, and numlen (0,0)
       > Found recordingfile column with type 12 with len 255, octetlen 255, and numlen (0,0)
       > Found cnum column with type 12 with len 40, octetlen 40, and numlen (0,0)
       > Found cnam column with type 12 with len 40, octetlen 40, and numlen (0,0)
       > Found outbound_cnum column with type 12 with len 40, octetlen 40, and numlen (0,0)
       > Found outbound_cnam column with type 12 with len 40, octetlen 40, and numlen (0,0)
       > Found dst_cnam column with type 12 with len 40, octetlen 40, and numlen (0,0)
ibx2*CLI>







ibx2*CLI> odbc show all

ODBC DSN Settings
-----------------

  Name:   asterisk-mysql
  DSN:    asterisk-mysql
    Last connection attempt: 1969-12-31 19:00:00
  Pooled: No
  Connected: Yes

  Name:   asteriskcdrdb
  DSN:    MySQL-asteriskcdrdb
    Last connection attempt: 2015-09-04 14:48:27





ibx2*CLI> cdr show status

Call Detail Record (CDR) settings
----------------------------------
  Logging:                    Enabled
  Mode:                       Simple
  Log unanswered calls:       No
  Log congestion:             No

* Registered Backends
  -------------------
    cdr-custom
    Adaptive ODBC



[HowTo] How to reset a FreePBX administrator password

If you forget your administrator login information for FreePBX, there is a simple way to log in and reset it. You will need your current root password to proceed with this tutorial.
  1. Log into your FreePBX server via SSH as the root user, using a tool such as PuTTY on Windows, or Terminal on Mac.
  2. Next, bring up your FreePBX web interface in a web browser. Once the page has loaded, press Ctrl + A on your keyboard to highlight everything on the page.
  3. Locate the unique session ID on the left side of the screen, and copy this string. It will look something like this: igg56njsp8bi0h4odqnupsq963
  4. In your PuTTY or terminal window, type the following (be sure to replace the unique string with your own, and press enter):
  5. [root@pbx ~]# amportal a u igg56njsp8bi0h4odqnupsq963
    Fetching FreePBX settings with gen_amp_conf.php..
    session unlocked!
    [root@pbx ~]#
  6. In your web browser, refresh the login page and you will be automatically logged in.
  7. Visit Admin -> Administrators and select your user on the right side of the page. At this point you can reset your password.