Soporte & Consultoria

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

sábado, 27 de febrero de 2016

Asterisk ARI

Saltar al final de los metadatos
Ir al inicio de los metadatos


Asterisk 12 introduces the Asterisk REST Interface, a set of RESTful APIs for building Asterisk based applications. This article will walk you though getting ARI up and running.
There are three main components to building an ARI application.
The first, obviously, is the RESTful API itself. The API is documented using Swagger, a lightweight specification for documenting RESTful APIs. The Swagger API docs are used to generate validations and boilerplate in Asterisk itself, along with static wiki documentation, and interactive documentation usingSwagger-UI.
Then, Asterisk needs to send asynchronous events to the application (new channel, channel left a bridge, channel hung up, etc). This is done using a WebSocket on /ari/events. Events are sent as JSON messages, and are documented on the REST Data Models page. (See the list of subtypes for the Message data model.)
Finally, connecting the dialplan to your application is the Stasis() dialplan application. From within the dialplan, you can send a channel to Stasis(), specifying the name of the external application, along with optional arguments to pass along to the application.

miércoles, 24 de febrero de 2016

Asterisk cmd GosubIf

Asterisk cmd GosubIf


Conditionally jump to a particular priority, extension, or context, saving the return address.



Asterisk 1.6 and up (?):


If condition is true and label1 points to a existing context|extension|priority or extension|priority or priority, then jump to that location, saving the return address. If condition is false, the same applies for label2.

Labels take the form '[context,]extension,]priority', so they can be (a) a priority, (b) an extension and a priority, or (c) a context, an extension and a priority.

Return Codes

Returns 0, or -1 if the given context, extension, or priority is invalid.


exten => maincid,1,Set(CALLERID(all)=Some Company <6153824758>)
exten => maincid,2,Return
exten => faxcid,1,Set(CALLERID(all)=Some Company <6153847735>)
exten => faxcid,2,Return

; External local
exten => _9NXXXXXX,1,GosubIf($[${CHANNEL:4:2} = 43]?faxcid,1:maincid,1)
exten => _9NXXXXXX,n,Dial(${TRUNK}/${EXTEN:1},,T)
; External long distance
exten => _91NXXXXXXXXX,1,GosubIf($[${CHANNEL:4:2} = 43]?faxcid,1:maincid,1)
exten => _91NXXXXXXXXX,n,Dial(${TRUNK}/${EXTEN:1},,T)
; External international
exten => _9011.,1,GosubIf($[${CHANNEL:4:2} = 43]?faxcid,1:maincid,1)
exten => _9011.,n,Dial(${TRUNK}/${EXTEN:1},,T)

; New/extended syntax:
GosubIf($["${CALLERID(num)}" =~ "1234567$"]?dial-some-special,${EXTEN},1(arg1,arg2):dial-as-usually,${EXTEN},1(arg1,arg2))

Asterisk func if


Conditional: Returns the data following '?' if true else the data following ':'




  • *CLI> show function IF
  • Resides in module

Return value

Returns the resulting string.


exten => s,1,Set(foo=${IF($[ ${x} = 7]?tval:fval)})

Another Example
exten => s,1,Set(mycid=${IF($[ ${CALLERID(num)} =102]?tval:fval)})
same=>n,Noop( value of ${mycid})

if caller id is  100 value of  ${mycid} is tval if  not is fval

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:
You can also set global variables from dialplan logic using the GLOBAL() dialplan function along with the Set() application. Simply use the syntax:
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, 23 de febrero de 2016

Asterisk sip transfer

how SIP does transfers. For a blind transfer, it acts like a redirect, where the calling phone is sent a new location. But for an attended transfer, you're setting up a whole new call, then bridging the two calls. That's why it acts the way it does.

sábado, 20 de febrero de 2016

Starting Asterisk Without Scripts

Asterisk can be loaded in a variety of ways. The easiest way is to start Asterisk by running the binary file directly from the Linux command-line interface. If you are running a system that uses the init.d scripts, you can easily start and restart Asterisk that way as well. However, the preferred way of starting Asterisk is via the safe_asterisk script.

Console Commands

The Asterisk binary is, by default, located at /usr/sbin/asterisk. If you run /usr/sbin/asterisk, it will be loaded as a daemon. There are also a few switches you should be aware of that allow you to (re)connect to the Asterisk CLI, set the verbosity of CLI output, and allow core dumps if Asterisk crashes (for debugging with gdb). To explore the full range of options, run Asterisk with the -h switch:
# /usr/sbin/asterisk -h       
Here is a list of the most commonly used options:
Console. This will start Asterisk as a user process (not as a server), and will connect you to the Asterisk CLI. This option is good when you are debugging your startup parameters, but should not be used for a normal system (if Asterisk is already running, this option will not work and will issue a complaint).
Verbosity. This is used to set the amount of output for CLI debugging. The more “v”s, the more verbose.
Core dump. If Asterisk were to crash unexpectedly, this would cause a core file to be created for later tracing with gdb. You generally do not use this in production, unless you are writing code for Asterisk and want to debug any resulting crashes.
Remote. This is used to reconnect remotely to an already running Asterisk process. (The process is remote from the standpoint of the console connecting to it but is actually a local process on the machine. This has nothing to do with connecting to a remote process over a network using a protocol such as IP, as this is not supported.) This is the most common option and it is what you would use to connect to Asterisk on a system where it is running as a daemon/service that was started by init at boot time.
-x "<CLI command>"
Execute. Using this command in combination with -r allows you to execute a CLI command without having to connect to the CLI and type it manually. An example would be to send a restart, which you would do by typing asterisk -rx "reload" from the command line.
Let’s look at some examples. If you want to start Asterisk as a user program (because you are tweaking your config and will be starting and stopping it several times), and you want a verbosity level of 3, use the following command:
# /usr/sbin/asterisk -cvvv      
If the Asterisk process is already running (for example, if you have installed Asterisk as part of the init process of the system), use the reconnect switch, like so:
# /usr/sbin/asterisk -vvvr    
If you want Asterisk to dump a core file after a crash, you can use the -g switch when starting Asterisk:
# /usr/sbin/asterisk -g       
To execute a command without connecting to the CLI and typing it (perhaps for use within a script), you can use the -x switch in combination with the -r switch:
# /usr/sbin/asterisk -rx "restart now"
# /usr/sbin/asterisk -rx "database show"
# /usr/sbin/asterisk -rx "sip show peers"        
If you are experiencing crashes and would like to output to a debug file, use the following command:
# /usr/sbin/asterisk -vvvvc | tee /tmp/debug.log     
Note that you do not have to use the v switch if you do not want the system to provide detailed output of what is going on. On a busy system, you may not want to get any output, as it can interfere with whatever you are doing on the console.

viernes, 19 de febrero de 2016

Asterisk acl.conf


or on  specifiy sip peer




sábado, 13 de febrero de 2016

Setting PJSIP device extension





jueves, 11 de febrero de 2016

FreePNX elastix duplicate key error adding trunks

DB Error: already exists
INSERT INTO sip (id, keyword, data, flags) values ('tr-peer-3',?,?,'0')

find the   DB PASS and user on  /etc/amporta.conf



mysql -user asteriskuser -pmypass  asterisk


mysql> delete from sip where id='tr-peer-3';