Docstoc

Netweb's Asterisk Guide for Newbies

Document Sample
Netweb's Asterisk Guide for Newbies Powered By Docstoc
					                                    netweb Group, Inc.
                                    385 Main St. Suite # 4A, Metuchen, NJ 08840
                                    Ph: 732-213-2422: email: info@netwebgroup.com
                                     We are your one source for VOIP and Broadband




                        Netweb’s
                      Asterisk Guide
                              for
                        Newbies




Netweb Confidential       Page 1                      Property of Netweb Group, Inc.
                                                                                                   netweb Group, Inc.
                                                                                                   385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                                   Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                                    We are your one source for VOIP and Broadband




Disclaimer:............................................................................................................................................. 4
   Introduction ......................................................................................................................................... 4
   What Is Asterisk™?.............................................................................................................................. 4
   Asterisk™ Architecture ...................................................................................................................... 5
       Installing Asterisk: ............................................................................................................................ 7
   Configuring Asterisk: ......................................................................................................................... 8
       sip.conf ........................................................................................................................................... 8
       ------------- ........................................................................................................................................ 8
       extensions.conf................................................................................................................................ 9
       ----------------------- ............................................................................................................................. 9
       voicemail.conf.................................................................................................................................. 9
       -------------------.................................................................................................................................. 9
   How to test your asterisk Box? ............................................................................................................ 10
   Links for more information:.............................................................................................................. 10
   Technical info about VoIP: ............................................................................................................... 10
   Asterisk with CDR (Call Detail Records) in MySQL ........................................................................... 10
Create MySQL Databases with MySQL Passwords as under: .................................................................... 12
   Official documentation ..................................................................................................................... 14
   More documentation and links: ........................................................................................................ 15
An unofficial Asterisk PBX HowTo page: http://megaglobal.net/docs/asterisk/html/ inaccessnetworks
H323 Channel Driver Tilghman's asterisk page (http://asterisk.drunkcoder.com/) Kapejod's
chan_capi + Asterisk page Asterisk PBX HOWTO (Beta Draft) NuFone Networks H323 Channel
Driver Cam Farnell's AGI Documentation Andreas Otto's DynExtenDB Module TDMoE HowTo
Asterisk Faq-O-Matic John Todd's Asterisk Page Wade Weppler's Asterisk Page Python Tools for
Asterisk Michael Jastremski has a script easing recording your own voice menus Asterisk is an open
source software PBX, created by Digium, Inc. and a continuosly growing user and developer base. Digium
invests in both developing the Asterisk source code and low cost telephony hardware that works with Asterisk.
Asterisk runs on Linux and other Unix platforms with or without hardware that connects your server to the
traditional global telephony network, the PSTN ......................................................................................... 15
   Channels - telephony connections to the PBX....................................................................................... 16
   Documentation .................................................................................................................................. 16
   Where to start .................................................................................................................................... 16
   If you mean business.......................................................................................................................... 16
   Applications..................................................................................................................................... 18
       Contexts and Extensions ................................................................................................................ 18
       Extension Patterns ......................................................................................................................... 18
   Managing asterisk - the manager’s interface .................................................................................... 19
   Asterisk - a platform for enterprise wide telephony .......................................................................... 19
   What is Good or Great About IAX Protocol:...................................................................................... 19
   Asterisk configuration...................................................................................................................... 20
   Development and scripting .............................................................................................................. 20
   More information:............................................................................................................................. 20
   Documentation................................................................................................................................. 20
   Where to start .................................................................................................................................. 20
Netweb Confidential                                                Page 2                                            Property of Netweb Group, Inc.
                                                                                                 netweb Group, Inc.
                                                                                                 385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                                 Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                                  We are your one source for VOIP and Broadband


   If you mean business ....................................................................................................................... 21
   Installation: ...................................................................................................................................... 21
   Detailed Installation Procedure is below: ......................................................................................... 21
   Billing .............................................................................................................................................. 23
   GUI Tools: ........................................................................................................................................ 24
   Speech Tools:.................................................................................................................................... 24
       SOX source is now available at: http://sox.sourceforge.net/ ............................................................... 24
       Convert WAV audio files for use in Asterisk ...................................................................................... 25
General commands for Asterisk Command Line ....................................................................................... 34
Server management............................................................................................................................... 35
AGI commands...................................................................................................................................... 35
Database handling commands ................................................................................................................ 35
IAX Channel commands ......................................................................................................................... 35
H323 channel commands ....................................................................................................................... 36
SIP channel commands.......................................................................................................................... 36
Zap channel commands.......................................................................................................................... 36
MGCP channel? commands ................................................................................................................... 36
skinny channel? commands .................................................................................................................... 37
CAPI channel? commands...................................................................................................................... 37
   Asterisk Dialplan Commands .............................................................................................................. 37
       Alphabetical list.............................................................................................................................. 40




Netweb Confidential                                               Page 3                                           Property of Netweb Group, Inc.
                                                                                     netweb Group, Inc.
                                                                                     385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                     Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                      We are your one source for VOIP and Broadband




Disclaimer:


This document contains information taken from WIKI and Asterisk web portal http://www.asterisk.org. This document may not be for
the beginners as this document assumes that the readers have some knowledge of Telephony In general and VOIP & LINUX in
particular. The configuration files listed in this document are fully tested and have been working on Netweb Group’s eezeePhone
Servers. Use the information contained in this document at your own risk. Copying or Distribution of this document for your personal
use is free but commercial use without prior permission of Netweb Group, Inc. is prohibited.



Introduction

Interested in setting up a PBX with Asterisk for your home or small office, but not sure where to start? Many of the experst were in the
same position a few months ago, struggling with the documentation, and trying to piece things together. Things do come together
eventually, but I thought I'd make an effort at an introduction to Asterisk for newbies, so here it is.

What Is Asterisk™?

Asterisk is software that turns a Linux box into a professional quality PBX using IP Telephony technologies. You don't have to know
every protocol and every acronym right now. You'll learn all of those in time. I got started by getting a TDM400P from Digium. This
piece focuses on using that card to bridge Asterisk to the analog phone world. This card allows you to talk to a POTS line provided by
Verizon for instance using an FXO interface, or a standard analog phone using an FXS interface. There are four slots so you can mix
and match. Once you get started though, I think you'll be so impressed with IP Phones that you'll give up your analog phones, and just
use the Digium card to bridge to your POTS phone lines.

Asterisk™ is a complete PBX in Software (whatever that means in general). It can run on any PC under Linux OS and provides all of
the features you would expect from a traditional Telephone PBX and more. Asterisk™ does voice over IP in three protocols(SIP, H323
and MGCP), and can interoperate with almost all standards-based telephony equipment using relatively inexpensive hardware.
Asterisk is an Open Source PBX and telephony toolkit. It is, in a sense, middleware between Internet and telephony channels on the
bottom, and Internet and telephony applications at the top. For more information on the project itself, please visit the Asterisk home
page at: http://www.asteriskpbx.com

Asterisk™ provides Voicemail services with Directory, Call Conferencing, Interactive Voice Response, Call Queuing. It has support for
three-way calling, caller ID services, ADSI, SIP and H.323 (as both client and gateway). Check the Features section for a more
complete list.

Asterisk™ needs no additional hardware for making Voice over IP calls. For interconnection with digital and analog telephony
equipment, Asterisk supports a number of hardware devices, most notably all of the hardware manufactured by Asterisk's™ sponsors,
Digium. Digium has single and quad span FXO cards for POTS lines, T1 and E1 interfaces for interconnection to PRI lines and
channel banks as well as a single port FXO card and a one to four-port modular FXS card.

Also supported are the Internet Line Jack and Internet Phone Jack products from Quicknet.

Asterisk™ supports a wide range of TDM protocols for the handling and transmission of voice over traditional telephony interfaces.
Asterisk™ supports US and European standard signaling types used in standard business phone systems, allowing it to bridge
between next generation voice-data integrated networks and existing infrastructure. Asterisk™ not only supports traditional phone
equipment, it enhances them with additional capabilities.




Netweb Confidential                                       Page 4                                       Property of Netweb Group, Inc.
                                                                                      netweb Group, Inc.
                                                                                      385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                      Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                       We are your one source for VOIP and Broadband


Using the Inter-Asterisk™ eXchange (IAX™) Voice over IP protocol, Asterisk™ merges voice and data traffic seamlessly across
disparate networks. While using Packet Voice, it is possible to send data such as URL information and images in-line with voice
traffic, allowing advanced integration of information.

Asterisk™ provides a central switching core, with four APIs for modular loading of telephony applications, hardware interfaces, file
format handling, and codecs. It allows for transparent switching between all supported interfaces, allowing it to tie together a diverse
mixture of telephony systems into a single switching network.

Asterisk™ is primarily developed on GNU/Linux for x86. It is known to compile and run on GNU/Linux for PPC along with OpenBSD,
FreeBSD, and Mac OS X Jaguar. Other platforms and standards based UNIX-like operating systems should be reasonably easy to
port for anyone with the time and requisite skill to do so. Asterisk is available in the testing and unstable Debian archives, maintained
thanks to Mark Purcell.

There is an unofficial site at www.voip-info.org that is very extensive and will probably answer most of your questions. Also a google
search in the digium mailinglists is of invaluable help. Just be careful with examples from the search, since the mailing lists hides text
with an '@' in, and as you might know, Asterisk config files has this, scrambling some of them up.

Get an ISDN card, a PC with some RAM, and install Asterisk. We managed to at least install it on a machine running RedHat 8.0 in
less than 15 minutes, included getting the source code and compiling it. (note; just the asterisk source) OReillynet has made a short
introduction of how to get it going.


Asterisk™ Architecture

Asterisk™ is carefully designed for maximum flexibility. Specific APIs are defined around a central PBX core system. This advanced
core handles the internal interconnection of the PBX, cleanly abstracted from the specific protocols, codecs, and hardware interfaces
from the telephony applications. This allows Asterisk to use any suitable hardware and technology available now or in the future to
perform its essential functions, connecting hardware and applications.

The Asterisk™ core handles these items internally:

PBX Switching - The essence of Asterisk™, of course, is a Private Branch Exchange Switching system, connecting calls together
between various users and automated tasks. The Switching Core transparently connects callers arriving on various hardware and
software interfaces.

Application Launcher - launches applications, which perform services for uses, such as voicemail, file playback, and directory listing.

Codec Translator - uses codec modules for the encoding and decoding of various audio compression formats used in the telephony
industry. A number of codecs are available to suit diverse needs and arrive at the best balance between audio quality and bandwidth
usage.

Scheduler and I/O Manager - handles low level task scheduling and system management for optimal performance under all load
conditions.
Loadable Module APIs:

Four APIs are defined for loadable modules, facilitating hardware and protocol abstraction. Using this loadable module system, the
Asterisk™ core does not have to worry with details of how a caller is connecting, what codecs are in use, etc.

Channel API - the channel API handles the type of connection a caller is arriving on, be it a VoIP connection, ISDN, PRI, Robbed bit
signaling, or some other technology. Dynamic modules are loaded to handle the lower layer details of these connections.

Application API - the application API allows various task modules to be run to perform various functions. Conferencing, Paging,
Directory Listing. Voicemail, In-line data transmission, and any other task, which a PBX system might perform now or in the future, are
handled by these separate modules.
Netweb Confidential                                        Page 5                                       Property of Netweb Group, Inc.
                                                                                      netweb Group, Inc.
                                                                                      385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                      Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                       We are your one source for VOIP and Broadband




Codec Translator API - loads codec modules to support various audio encoding and decoding formats such as GSM, Mu-Law, A-
law, and even MP3.

File Format API - handles the reading and writing of various file formats for the storage of data in the file system.

Using these APIs Asterisk™ achieves a complete abstraction between its core functions as a PBX server system and the varied
technologies existing (or in development) in the telephony arena. The modular form is what allows Asterisk™ to seamlessly integrate
both currently implemented telephony switching hardware and the growing Packet Voice technologies emerging today. The ability to
load codec modules allows Asterisk™ to support both the extremely compact codec necessary for Packet Voice over slow
connections such as a telephone modem while still providing high audio quality over less constricted connection types. The
application API provides for flexible use of application modules to perform any function flexibly on demand, and allows for open
development of new applications to suit unique needs and situations. In addition, loading all applications as modules allows for a
flexible system, allowing the administrator to design the best suited path for callers on the PBX system and modify call paths to suit
the changing communication needs of a going concern

Downloading Asterisk™

You can download a tar ball of the released sources at ftp://ftp.asterisk.org/pub/telephony.

You'll need Asterisk™, and if you're using Digium's™ hardware you'll need zaptel. For T1 or E1 interfaces you'll also need libpri. You
will need bison on your favorite LINUX distro in order to build Asterisk™.

The ncurses and ncurses-devel packages are required to build if you wish to build the newt tools (e.g. astman). Installation should be
in this order:

The fastest way to obtain Asterisk™ is to use CVSup.
To check out Asterisk™ using CVSup, create a sup file as follows:

default host=cvs.digium.com
default base=/usr/src
default release=cvs tag=.
default delete use-rel-suffix

Modules required are:

asterisk
libpri
zaptel

Perhaps call it "asterisk-sup" and put it in /usr/src

Then simply:
# cd /usr/src
# cvsup asterisk-sup
Or, you can obtain Asterisk™ by checking out a fresh copy from our CVS Server.
To check out code from our CVS repository:
# cd /usr/src
# export CVSROOT=:pserver:anoncvs@cvs.digium.com:/usr/cvsroot
# cvs login                    - the password is anoncvs.
# cvs checkout zaptel libpri asterisk


After you recieve the latest code from CVSup or CVS, issue the following commands as root to install Asterisk™ on your system:
Netweb Confidential                                       Page 6                                        Property of Netweb Group, Inc.
                                                                                      netweb Group, Inc.
                                                                                      385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                      Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                       We are your one source for VOIP and Broadband


# cd zaptel
# make clean; make install
# cd ../libpri
# make clean; make install
# cd ../asterisk
# make clean; make install

Things you will want to install Asterisk and/or Zaptel:

ncurses, and associated -devel
openssl, and associated -devel
bison, and associated -devel
Linux 2.4 kernel sources

Installing Asterisk:

Here are the ways to do it:
RedHat 7.3, 8.0, 9.0 -> Download the RPMs from http://www.asterisk.org. How others did it with RedHat from scratch.
GenToo, just do an 'emerge -u asterisk'. If you need iax, install that as well ('emerge -u iax')
Debian, "apt-get install asterisk". You should check what version is available, since it might be really old. In case you would like the
latest, put the following two lines in your /etc/apt/sources.list file:

   deb http://www.backports.org/debian stable asterisk
   deb-src http://www.backports.org/debian stable asterisk

Then do a "apt-get update", then try the "apt-get install asterisk" again.

How we did it.

     1.    Have a Linux running 2.4.x kernel with readlib and openssh installed (incl. development packages) (A RH 8.0 machine)
     2.    Download latest version of asterisk from their CVS system.
     3.    run:

             make clean ; make install

           in the asterisk directory. (and in zaptel and libpri if you are using that hardware. Remember to do the make in the correct
           order; zaptel, libpri, asterisk.


     4.    For the first time using asterisk, run:
     5.      make samples

           This makes a test configuration which allows you to make some simple calls and test out latency with an echo test, after you
           have started it with the next step.


     6.    Now you are ready to run Asterisk, just type:

           asterisk -vvvc

           (it is in verbose mode with the "v" and the "c" connects you to the console)
Netweb Confidential                                        Page 7                                       Property of Netweb Group, Inc.
                                                                                         netweb Group, Inc.
                                                                                         385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                         Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                          We are your one source for VOIP and Broadband


I have put a link to the README file from the asterisk version CVS-06/13/03, so you can have a look at it before downloading the
whole source tree.

Now it is installed and running. After the long list of startup text, the prompt looks like this:
Asterisk Ready.
*CLI>
It is wise to have a look through all the text that came when asterisk started, to check for errors. We noticed some problems with our
soundcard that had to be corrected.

Configuring Asterisk:

Here is a sample-working configuration for asterisk. Currently we are discussing only four important configuration files.

     •      Sip.conf               -         User Configuration file for SIP Authentication
     •      Iax.conf               -         User Configuration file for IAX/IAX2 Authentication
     •      Extensions.conf        -         User Configuration file for Call handling
     •      Voicemail.conf         -         User Configuration file for VoiceMail

                                                                      sip.conf
                                                                     -------------
[general]

port = 5060               ; Port to bind the SIP Protocol to (SIP is 5060)
bindaddr = 67.109.153.236 ; Address to bind to (all addresses on machine)
allow=all                 ; Allow all codecs
context = bogon-calls     ; Send SIP callers that we don't know about to this context

[2000]
type=friend               ; This device takes and makes calls
username=2000             ; Username on device
secret=2000               ; Password for device
host=dynamic             ; This host is not on the same IP address every time
context=from-sip         ; Inbound calls from this host go here
mailbox=200              ; Activate the message waiting light if this
nat=yes                  ; voice mailbox has messages in it




[2001]                ; Duplicate of 2000, except with different auth data

type=friend
username=2001
secret=2001
host=dynamic
context=from-sip
mailbox=2001
nat=yes

[2002]                ; Duplicate of 2000, except with different auth data

type=friend
username=2002
Netweb Confidential                                            Page 8                                      Property of Netweb Group, Inc.
                                                                                   netweb Group, Inc.
                                                                                   385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                   Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                    We are your one source for VOIP and Broadband


secret=2002
host=dynamic
context=from-sip
mailbox=2002
nat=yes


                                                         extensions.conf
                                                         -----------------------
[general]

static=yes        ; These two lines prevent the command-line interface
writeprotect=yes ; from overwriting the config file. Leave them here.

[bogon-calls]

exten => _.,1,Congestion
exten => _.,1,Congestion

[from-sip]

exten => 2000,1,Dial(SIP/2000,20)
exten => 2000,2,Voicemail(u2000)
exten => 2000,102,Voicemail(b2000)
exten => 2000,103,Hangup


exten => 2001,1,Dial(SIP/2001,20)
exten => 2001,2,Voicemail(u2001)
exten => 2001,102,Voicemail(b2001)
exten => 2001,103,Hangup

;New one
exten => 2002,1,Dial(SIP/2002,20)
exten => 2002,2,Voicemail(u2002)
exten => 2002,102,Voicemail(b2002)
exten => 2002,103,Hangup


exten => 2999,1,VoicemailMain(${CALLERIDNUM})


                                                          voicemail.conf
                                                           -------------------
[general]

format=wav

[local]

;
; format: password, name, email address for attached voicemail msgs
;

Netweb Confidential                                     Page 9                                       Property of Netweb Group, Inc.
                                                                                    netweb Group, Inc.
                                                                                    385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                    Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                     We are your one source for VOIP and Broadband


2000 => 4321,JohnDoe,JohnDoe@yahoo.com
2001 => 8383,JohnDoe,JohnDoe@yahoo.com

If you come across errors while connecting, try changing

bindaddress=<your-ip-address> in sip.conf under [general] section.

How to test your asterisk Box?

To test your asterisk box, you have to configure soft phones such as X-Lite or X-Pro as per user id and password you have given in
sip.conf file while configuration of your asterisk box.

You will find more info in file x-lite-configuration.ppt in directory Doc-ppt.
Double click below to find out how to configure X-Lite SIP SoftPhone Dialer.

                                            X-Lite Configuration
                                             X-Lite




                                                                                 <= Double click

You can get detail information about asterisk in handbook below.

Double click below to find out to get asterisk handbook.pdf.



                                                           handbook-draft.pdf


Links for more information:
    • http://www.automated.it/guidetoasterisk.htm
    • http://www.marlow.dk/tech/asterisk.php?noframe=yes
    • http://www.onlamp.com/lpt/a/3956

Technical info about VoIP:
    • http://www.bertolinux.com/voip/english/VoIP-HOWTO-4.html
    • http://www.voip-info.org/

Asterisk with CDR (Call Detail Records) in MySQL

Follow the instructions on http://www.asterisk.org/index.php?menu=download for CVS download

cd /usr/src
cvs checkout asterisk-addons

copy the sample configuration file to /etc/asterisk/cdr_mysql.conf & edit it according to your requirements edit the modules.conf to
load cdr_addon_mysql.so

You must have mysql (Server and Client) and mysql-devel packages installed. In an RPM-based Linux, you can check presence of
MySQL like this:
Netweb Confidential                                        Page 10                                    Property of Netweb Group, Inc.
                                                                                        netweb Group, Inc.
                                                                                        385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                        Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                         We are your one source for VOIP and Broadband


rpm -qa | grep mysql

A sample configuration file, can be found on the cdr_mysql.conf page.

This is a sample configuration that assumes the SQL server is local.

[global]
 hostname=localhost
 dbname=asteriskcdrdb
 password=netwebcdrdb
 user=asteriskcdrdb
 ;port=3306
 ;sock=/tmp/mysql.sock

Table definitions for Asterisk cdr_mysql
This is the database definition you use to install in Mysql to support billing. Create the database using the following
Script:
# mysqladmin create database asteriskcdrdb [-p] ; add -p if you need to connect with a password
mysql --user=root [-p]

mysql> GRANT ALL PRIVILEGES
 -> ON asteriskcdrdb.*
 -> TO asteriskuser@localhost
 -> IDENTIFIED BY 'yourpassword';

 USE asteriskcdrdb;
 CREATE TABLE cdr (
   uniqueid varchar(32) NOT NULL default '',
   userfield varchar(255) NOT NULL default '',
   accountcode varchar(20) NOT NULL default '',
   src varchar(80) NOT NULL default '',
   dst varchar(80) NOT NULL default '',
   dcontext varchar(80) NOT NULL default '',
   clid varchar(80) NOT NULL default '',
   channel varchar(80) NOT NULL default '',
   dstchannel varchar(80) NOT NULL default '',
   lastapp varchar(80) NOT NULL default '',
   lastdata varchar(80) NOT NULL default '',
   calldate datetime NOT NULL default '0000-00-00 00:00:00',
   duration int(11) NOT NULL default '0',
   billsec int(11) NOT NULL default '0',
   disposition varchar(45) NOT NULL default '',
   amaflags int(11) NOT NULL default '0'
);

Hint: Copy and paste this SQL command into a text file, save it under an appropriate name, then execute the following command:

# mysql -u username -p password databasename < nameoftextfile

An interesting note: the name of the table, 'cdr', is hard-coded into the mysql interface, so if the table is created under a different
name, the mysql CDR backend will not work.

To setup interface between Asterisk and Voice any external VOIP gateways you need…
    • asterisk-oh323
Netweb Confidential                                        Page 11                                        Property of Netweb Group, Inc.
                                                                                  netweb Group, Inc.
                                                                                  385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                  Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                   We are your one source for VOIP and Broadband


        •   openh323
        •   pwlib

To dial out of your asterisk box you have to have make use of Dial() command as follows,
e.g.
            exten => _.,1,dial(SIP/BYEXTENSION@VM-IP:5061)

which transfer any number in dialed on IP phone to your VM-IP(Voice Master IP) on port 5061. Default port is 5060.

Now according to our configuration we are about to make asterisk work as converter from H.323 to SIP.

To make it work edit Extensions.conf as,

[general]
static=yes
writeprotect=yes

[sip]

exten => _.,1,dial(H323/BYEXTENSION@VM-IP:PORT)

[h323]

exten => _.,1,dial(SIP/BYEXTENSION@VM-IP:PORT)

Also open h323.conf as,

[general]
port = PORT
bindaddr =IP-ADDRESS

disallow=all
;allow=all               ; turns on all installed codecs
;disallow=g723.1         ; Proprietary, don't use it...
allow=g729
allow=g723.1
allow=ulaw
allow=alaw
allow=gsm              ; Always allow GSM, it's cool :)

dtmfmode=rfc2833

AllowGKRouted = no

context=h323 ; Note this

;end of file

Create MySQL Databases with MySQL Passwords as under:


                      Username              Database                          Password
                      root                  -                                 MyPassword1
                      asteriskcdrdb         Asteriskcdrdb                     MyPassword2
Netweb Confidential                                         Page 12                                 Property of Netweb Group, Inc.
                                                                                     netweb Group, Inc.
                                                                                     385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                     Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                      We are your one source for VOIP and Broadband




The configuration

Now we'll check out how it can be configurated to our needs.
The config files are all located in /etc/asterisk

The grammar of Asterisk varies from one config file to another, however the configuration files can generally be divided into three
categories which will be detailed more closely in the following sections:

     •     Interface Configuration - These types of files typically configure channel interfaces which bind directly to physical
           hardware. Examples include adtranvofr.conf, alsa.conf, modem.conf, oss.conf, phone.conf, and zapata.conf.
     •     Simple Groups - These types of files define the existence of various simple entities, like mailboxes, conference rooms, etc.
           Examples include extensions.conf, logger.conf, meetme.conf, musiconhold.conf, parking.conf, and voicemail.conf.
     •     Individual Entities - These configs detail a number of typically unrelated entities, like clients and servers and are used
           most often for VoIP services. Examples include iax.conf, oh323.conf, and sip.conf. Then next thing you need to do, is to
           specify the user in the correct file:
                o iax.conf - The user is using the Asterisk own IAX protocol
                o sip.conf - The user is using SIP
                o oh323.conf - The user is using H.323

Here is an example from the iax.conf file, since the user has an IAX client
[usken]
type=user
context=default
context=local
auth=plaintext
secret=hemmelig
callerid="Sjur Eivind Usken" <735 57966>
deny=0.0.0.0/0.0.0.0
accountcode=usken
permit=158.38.38.0.0/255.255.0.0

Note:
The ";" comments text because the "#" is used in several configuration lines and therefore can of course not be used.

Challenges

No sound on SIP
I had a "allow=all" codecs in the 'sip.conf' while which sort of "stopped" all sound out. I commented it out, and it was up and running
on the sound. Now I just allow for the g.711 codec with

disallow=all
allow=ulaw

Problem
Finding the ISDN card
We use an EICON DIVA 2.01 pci ISDN card and loaded the ISDN4Linux module HISAX. This had to be with the syntax:

[root@localhost]# modprobe HISAX type=11 protocol=2 id=HiSax" irq=9


Netweb Confidential                                       Page 13                                      Property of Netweb Group, Inc.
                                                                                   netweb Group, Inc.
                                                                                   385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                   Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                    We are your one source for VOIP and Broadband


The last two syntaxes, the ID and irq, is probably not needed for you, but I used them anyway.

Problem
Can't save the CDR for a call.

Technical (in Asterisk CLI)
Feb 27 12:09:13 ERROR[15372]: cdr_csv.c:219 csv_log: Unable to re-open master file /var/log/asterisk//cdr-csv//Master.csv
The Fix!
root@viper:/var/log/asterisk# cd cdr-csv/
root@viper:/var/log/asterisk/cdr-csv# ls
total 4
-rw-r--r-- 1 root root 0 Feb 22 06:25 Master.csv
-rw-r--r-- 1 root root 575 Feb 16 12:01 Master.csv.1
root@viper:/var/log/asterisk/cdr-csv# chown -R asterisk:asterisk Master.csv*
root@viper:/var/log/asterisk/cdr-csv# ls
total 4
-rw-r--r-- 1 asterisk asterisk 0 Feb 22 06:25 Master.csv
-rw-r--r-- 1 asterisk asterisk 575 Feb 16 12:01 Master.csv.1
root@viper:/var/log/asterisk/cdr-csv#

Problem
Voicemail is not working, just hanging up.

Technical (in Asterisk CLI)
Feb 27 12:04:15 WARNING[14348]: file.c:829 ast_writefile: Unable to open file
/var/spool/asterisk/voicemail/default/590/INBOX/msg0000.WAV: Permission denied
-- x=0, open writing: /var/spool/asterisk/voicemail/default/590/INBOX/msg0000 format: wav49, (nil)
Feb 27 12:04:15 WARNING[14348]: app_voicemail.c:1263 play_and_record: Error creating writestream
'/var/spool/asterisk/voicemail/default/590/INBOX/msg0000', format 'wav49'
Feb 27 12:04:15 WARNING[14348]: app_voicemail.c:601 base_encode: Failed to open log file:
/var/spool/asterisk/voicemail/default/590/INBOX/msg0000.WAV: No such file or directory

The Fix!

root@viper:/var/spool/asterisk/voicemail/default# chown -R asterisk:asterisk ???
root@viper:/var/spool/asterisk/voicemail/default# ls
total 48
drwxr-xr-x 3 asterisk asterisk 4096 Feb 16 11:32 1234

Links

The best so far! The VoIP Forum - http://www.voip-forum.org
Junghanns Tips&Trics with Asterisk - http://www.junghanns.net/asterisk/

Official documentation
The mailinglist: http://lists.digium.com/pipermail/asterisk-users/
Asterisk Official Site
The Official Asterisk Handbook at Digium
Asterisk Whitepaper by Mark Spencer
Asterisk Documentation by Mack Allison of LSS


Netweb Confidential                                        Page 14                                   Property of Netweb Group, Inc.
                                                                                        netweb Group, Inc.
                                                                                        385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                        Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                         We are your one source for VOIP and Broadband


More documentation and links:
http://megaglobal.net/docs/asterisk/html/

     inaccessnetworks H323 Channel Driver
     Tilghman's asterisk page (http://asterisk.drunkcoder.com/)
     Kapejod's chan_capi + Asterisk page
     Asterisk PBX HOWTO (Beta Draft)
     NuFone Networks H323 Channel Driver
     Cam Farnell's AGI Documentation
     Andreas Otto's DynExtenDB Module
     TDMoE HowTo
     Asterisk Faq-O-Matic
     John Todd's Asterisk Page
     Wade Weppler's Asterisk Page
     Python Tools for Asterisk
     Michael Jastremski has a script easing recording your own voice menus

     Asterisk is an open source software PBX, created by Digium, Inc. and a continuously growing user and developer base. Digium
     invests in both developing the Asterisk source code and low cost telephony hardware that works with Asterisk. Asterisk runs on
     Linux and other Unix platforms with or without hardware that connects your server to the traditional global telephony network, the
     PSTN

     Asterisk gives you real-time connectivity on both PSTN and VoIP networks. With Asterisk as your telephony switching platform,
     PBX, you’ll not only have a high-class PBX replacement. Asterisk is much more than the standard PBX. With Asterisk in your
     network, you can do telephony in new ways.

           1.    SIP Channel Module: The SIP Channel Module enables Asterisk to communicate via VOIP with SIP telephones and
                 exchanges. Asterisk is able to act as

           2.    a SIP client: This means that Asterisk registers as a client to another SIP server and receives and places calls to this
                 server. Incoming calls are routed to an Asterisk extension.

           3.    a SIP server: Asterisk can be configured so that SIP clients (phones, software clients) register to the Asterisk server
                 and set up SIP sessions with the server, i.e. calls and answers incoming calls. This said, Asterisk is not a full-feature
                 SIP server like SIP express router.

           4.    a SIP gateway: Asterisk acts as a Media gateway between SIP, IAX, MGCP, H.323 and PSTN connections. As an
                 example, an Asterisk server can be connected to ISDN to give your SIP clients connectivity to the switched telephony
                 (PSTN) network.

     Asterisk includes many features only found in top-of-the-line unified messaging systems, like
          • Connecting employees working from home to the office PBX over broadband connections
          • Connecting offices in various states over VoIP, Internet or a private IP network
          • Giving all employees voicemail, integrated with the Web and their E-mail
          • Building interactive voice applications, that connect to your ordering system or other inhouse applications
          • Giving access to the company PBX for business travellers, connecting over VPN from airport or hotel WLAN hotspots
     ...and much more

     Asterisk includes many features only found in top-of-the-line unified messaging systems, like
          • Music-on-hold for customers waiting in queues, supporting streaming media as well as MP3 music
          • Call queues where call agents jointly handle answering incoming calls and monitor the queue
          • Text-to-speech system integration (the Festival Open Source speech synthesis software can be integrated)
          • Call data record (CDR) generation for integration with billing systems
Netweb Confidential                                         Page 15                                       Property of Netweb Group, Inc.
                                                                                        netweb Group, Inc.
                                                                                        385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                        Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                         We are your one source for VOIP and Broadband


               •     Voice recognition system integration (such as the Sphinx Open Source voice recognition software)
               •     The ability to interface with normal telephone lines, ISDN basic rate and primary rate interfaces

    This document is an introduction to the Asterisk architecture, to guide you as you discover this complex, yet so powerful, open source
    software.
    Channels - telephony connections to the PBX
    Asterisk channels are drivers for various kinds of connections, both to VoIP protocols like SIP, IAX, MGCP and H.323 and to
    hardware that connect to the PSTN, like Zaptel?, ISDN BRI and PRI and other devices.

    Telephones and software phones connect to a channel. Some of them log in, or “register” to show that they are reachable, on line.
    Channels also register for outbound connections to other VoIP server, with SIP to the Free World Dialup network or to SIP providers
    like Nufone, Vonage and Siphone? or with IAX to IAXtel.com.

     Documentation
    Digium has a draft Asterisk handbook, a PDF file you can download and read. It is a good introduction to Asterisk, the configuration
    files and dial plan contexts. More up to date reference information on applications and a lot of tricks and tips are found on this web
    site, the Voip-info Wiki.
     Where to start
    You start on the Asterisk home page - http://www.asterisk.org (cache) - and choose the download item in the menu. There you’ll find
    information on how to get releases from the FTP server or download to the latest development source code in the CVS repository.
    After that continue with the installation tips. If you’re in a hurry to get started, check the quickstart page.
     If you mean business
    •          Asterisk rollout tips

    Where to start
    You start on the Asterisk home page - http://www.asterisk.org - and choose the download item in the menu. There you’ll find
    information on how to get releases from the FTP server or download to the latest development source code in the CVS repository.
    After that continue with the installation tips. If you’re in a hurry to get started, check the quickstart page.




    •         Asterisk channels: Overview
o   Asterisk SIP channels: The SIP channel
o   Asterisk IAX channels: The Inter-Asterisk-Exchange channel, that
o   connects Asterisk servers




    Netweb Confidential                                       Page 16                                     Property of Netweb Group, Inc.
                                netweb Group, Inc.
                                385 Main St. Suite # 4A, Metuchen, NJ 08840
                                Ph: 732-213-2422: email: info@netwebgroup.com
                                 We are your one source for VOIP and Broadband




Netweb Confidential   Page 17                     Property of Netweb Group, Inc.
                                                                                       netweb Group, Inc.
                                                                                       385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                       Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                        We are your one source for VOIP and Broadband


Protocols - bits and bolts of Voice over IP or Internet Telephony
Asterisk supports many protocols for voice over IP. Both signalling protocols like H.323 and SIP and media transport protocols like
RTP are included. Each channel supports one or more protocols. The media streams, the actual voice over the net, can be coded with
many different algorithms, ranging from alaw/ulaw (G.711) to GSM and ILBC.

Applications
To connect incoming calls to outbound connections or other local users asterisk consist of many applications, command you use to
create a working PBX. From simple logic like goto to more complex applications like voicemail and conference calls.

Connecting it all - The dial plan:
http://www.voip-info.org/wiki-Asterisk+config+extensions.conf
The Dialplan is configured in the extensions.conf file. It is Asterisk’s most important configuration file. It controls how all incoming and
outgoing calls are routed and handled.
This is where you control the behaviour for all connections through your PBX.
[general]
At the top of your extensions.conf file, you configure a few general settings in the section headed [general]. For details, see:
Dialplan General Settings
[globals]
Next, in the [globals] section, you may define global variables (or constants) and their initial values. For details, see:
Dialplan Global Variables
                                                        Contexts and Extensions
After the [general] and [globals] categories, the remainder of the extensions.conf file is taken up by the definition of the Dialplan. The
Dialplan consists of a collection of contexts. Each context consists of a collection of extensions. For an introduction to these topics,
see:
Introducing Contexts and Extensions
                                                            Extension Patterns
When you define the extensions within a context, you may not only use literal numbers, not only alphanumeric names, but also you
may define extensions that match whole sets of dialed numbers by using extension patterns. For more information about this, see:
Extension Names and Patterns

The dial plan is stored in a text file, the configuration file extensions.conf. In this file actions are connected to extensions. Each
extension belongs to a context, either the default context or a specific context you create, like incoming sip calls, long-distance
outbound PSTN calls, local calls, inter-office calls or something else. Users connecting to asterisk all belong to a context (specified in
the channel configuration file), which is where asterisk look for advice on how to handle the calls placed by that user, checking the
access rights to expensive lines, with different rule sets for local users and contacts calling from an outside line.

In the dial plan, you set up all actions and situations that the PBX should handle. You can configure contexts that work only during
part of the day or night-time. You can include context from other context and either simplify or make a very complicated dial plan...

Examples of what you can do is:
•        Connect a call to voicemail if a user does not answer primary or secondary phone within
         20 seconds
•        Connect a call to a multi-party conference
•        Transfer calls to another Asterisk pbx
•        Block calls from an unidentified or unwanted caller
•        Look up data in a database based on a query on the callers ID, decide which group of
         agents that should answer the call
•        Create call queues and let group of agents handle the incoming calls
More information:
•        Asterisk config extensions.conf
•        Asterisk tips and tricks



Netweb Confidential                                       Page 18                                        Property of Netweb Group, Inc.
                                                                                     netweb Group, Inc.
                                                                                     385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                     Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                      We are your one source for VOIP and Broadband


Managing asterisk - the manager’s interface
Asterisk runs in the background of a Linux or Unix system FreeBSD or OpenBSD. Most functionality today is based on Linux. As a
manager, you can connect to a running Asterisk PBX with a command line interface, or one of serveral graphical interfaces.

The CLI gives the manager the power to
•        Follow what happens in the PBX on line
•        Debug various protocols as clients connect and place calls
•        See active users and active calls
•        Change data in the asterisk database
•        Reload configurations into the running PBX

There’s also an TCP/IP based interface for management, that the Asterisk addon applications use. This gives the manager or user an
oppurtunity to watch the Asterisk server in real-time, see connections coming up and shutting down as well as the ability to originate
connections.

More information:
•        Asterisk CLI
•        Asterisk GUI

Asterisk - a platform for enterprise wide telephony
Asterisk servers are able to set up trunking connections between the various offices using a special Inter-Asterisk exchange protocol
(IAX). This protocol supports many simultaneous connections and easily work over NAT connections. This way, you can build least-
cost-routing for calls and have load-balancing between the Asterisk servers in your network.

What is Good or Great About IAX Protocol:
1) IAX is more efficient on the wire than RTP for *any* number of calls, *any* codec. The benefit is anywhere from 2.4k for a single
call to approximately trippling the number of calls per megabit for G.729 when measured to the MAC level when running trunk mode.

 2) IAX is information-element encoded rather than ASCII encoded. This makes implementations substantially simpler and more
robust to buffer overrun attacks since absolutely no text parsing or interpretation is required. The IAXy runs its entire IP stack, IAX
stack, TDM interface, echo canceller, and callerid generation in 4k of heap and stack and 64k of flash. Clearly this demonstrates the
implementation efficiency of its design. The size of IAX signalling packets is phenomenally smaller than those of SIP, but that is
generally not a concern except with large numbers of clients frequently registering. Generally speaking, IAX2 is more efficient in its
encoding, decoding and verifying information, and it would be extremely difficult for an author of an IAX implementation to somehow
be incompatible with another implementation since so little is left to interpretation.

3) IAX has a very clear layer2 and layer3 separation, meaning that both signalling and audio have defined states, are robustly
transmitted in a consistant fashion, and that when one end of the call abruptly disappears, the call WILL terminate in a timely fashion,
even if no more signalling and/or audio is received. SIP does not have such a mechanism, and its reliability from a signalling
perspective is obviously very poor and clumsy requiring additional standards beyond the core RF3261. \

4) IAX's unified signalling and audio paths permit it to transparently navigate NAT's and provide a firewal administrator only a *single*
port to have to open to permit its use. It requires an IAX client to know absolutely nothing about the network that it is on to operate.
More clearly stated, there is *never* a situation that can be created with a firewall in which IAX can complete a call and not be able to
pass audio (except of course if there was insufficient bandwidth).

5) IAX's authenticated transfer system allows you to transfer audio and call control off a server-in-the-middle in a robust fashion such
that if the two endpoints cannot see one another for any reason, the call continues through the central server.

Netweb Confidential                                      Page 19                                       Property of Netweb Group, Inc.
                                                                                         netweb Group, Inc.
                                                                                         385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                         Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                          We are your one source for VOIP and Broadband


6) IAX clearly separates Caller*ID from the authentication mechanism of the user. SIP does not have a clear method to do this unless
Remote-Party-ID is used.

7) SIP is an IETF standard. While there is some fledgling documentation courtesy Frank Miller, IAX is not a published standard at this
time.

8) IAX allows an endpoint to check the validity of a phone number to know whether the number is complete, may be complete, or is
complete but could be longer. There is no way to completely support this in SIP.

9) IAX always sends DTMF out of band so there is never any confusion about what method is used. 10) IAX support transmission of
language and context, which are useful in an Asterisk environment. That's pretty much all that comes to mind at the moment.

 Asterisk configuration
All of Asterisk is configured in text files, the Asterisk config files, that are placed in the /etc/asterisk directory on a standard install. In
the standard distribution, there are sample files with a lot of comments, explaining various configuration options.

More information:
•        Asterisk config files: Overview
•        Asterisk config extensions.conf: The dial plan - the key to all functionality in the PBX
•        Channel configurations: sip.conf, iax.conf, mgcp.conf and more...
•        Application configurations: voicemail, meetme conferencing and more


 Development and scripting
If you want to add on to Asterisk, there are many ways to add functionality.
•         Using the applications in the dial plan to build solutions. There are scripting commands
          like gotoif, variables to test and set and string handling functions to control what
          happens when a user dials an extension
•         agi: The application interface for extending the dialplan with your functionality in the
          language you choose - PHP, Perl, C, Java, Unix Shell and others
•         manager: The manager API for connecting to the PBX from your application
•         And the C API, documented in the source codes and documentation you generate from
          within the source code tree

Note that Asterisk is licensed by Digium with the GPL? license. If you add functions with the C API and want to distribute this solution
to customers, you need to contact Digium to sort out the licensing. If you want to join the project and add functionality to the Asterisk
source code under GPL, you need to wave the rights to the code to Digium. Many developers from all over the world contribute to
Asterisk, you are most welcome to join.

More information:
•        Asterisk.org (cache): Documentation, IRC, bug tracker, links, cvs download information
•        Digium (cache): Hardware, licensing, commercial support, links to commercial partners

 Documentation
Digium has a draft Asterisk handbook, a PDF file you can download and read. It is a good introduction to Asterisk, the configuration
files and dial plan contexts. More up to date reference information on applications and a lot of tricks and tips are found on this web
site, the Voip-info Wiki.

 Where to start
You start on the Asterisk home page - http://www.asterisk.org (cache) - and choose the download item in the menu. There you’ll find
information on how to get releases from the FTP server or download to the latest development source code in the CVS repository.
After that continue with the installation tips. If you’re in a hurry to get started, check the quickstart page.

Netweb Confidential                                         Page 20                                        Property of Netweb Group, Inc.
                                                                                  netweb Group, Inc.
                                                                                  385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                  Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                   We are your one source for VOIP and Broadband




If you mean business

Asterisk rollout tips


Installation:

if you want to do a fresh Install of Asterisk, you can always do it from below:
http://www.asterisk.org/index.php?menu=download

Asterisk Tips and Tricks are below:
http://www.voip-info.org/wiki-Asterisk+tips+and+tricks

Detailed Installation Procedure is below:

1) Get your machine ready to compile software

#apt-get update && apt-get upgrade
#apt-get install bison cvs openssl libssl-dev libasound2-dev libc6-dev
Setup UNIXodbc, if you want Call Detail Record Logging (the -dev packages allow you to compile
against a package)
#apt-get install unixodbc-dev

2) Set up the kernel source, make *sure* you have a 2.4 kernel.

I used a 2.4.19 kernel, you can do your own thing here.

cd /usr/src/
bunzip2 kernel-source-2.4.19.tar.bz
tar xvf kernel-source-2.4.19.tar
cd linux-2.4.19
make menuconfig
make dep (I seemed to need this, may not?)
cd /usr/src
ln -s linux-2.4.19 linux
ln -s linux-2.4.19 linux-2.4 (Saw a reference to this in the zaptel compile,
still needed)
3) Install Digium Drivers or Clock Source

If you want conferencing, you REALLY should have a Digium card, ztdummy or use zaprtc.
I have used a TE410P in my first server, and zaprtc all others.
See http://www.voip-info.org/wiki-Asterisk+timer

#cd /usr/src
#export CVSROOT:=:pserver:anoncvs@cvs.digium.com:/usr/cvsroot
#cvs login (the password is anoncvs)

(For Digium Card and T1 support)
#cvs checkout zaptel libpri
(this makes directories right in /usr/src)
Netweb Confidential                                       Page 21                                   Property of Netweb Group, Inc.
                                                                  netweb Group, Inc.
                                                                  385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                  Ph: 732-213-2422: email: info@netwebgroup.com
                                                                   We are your one source for VOIP and Broadband



(Always build drivers before asterisk)
cd zaptel
make clean; make install

cd ../libpri
make clean; make install
4) Compile Asterisk
(For stable asterisk)
#cvs checkout -r v1-0_stable asterisk

(For extra sounds)

(Now the good stuff, check for missing libraries)
cd ../asterisk
make clean; make install
Keep an eye on missing files. Assuming all goes well, asterisk will be installed.

5) Configure Hardware and Start Asterisk

You'll also need to edit /etc/zaptel.conf to configure your Digium hardware.

Try modprobing your hardware. Add any hardware to /etc/modules.conf (I added wct4xxp).
NOTE: I had to do "hdparm -u 1 /dev/hda" to keep my te410P interrupt errors from filling the
screen.

If this is your first installation, go ahead and do a "make samples". This will give you the default
config files.

Now you are ready for your big test -- starting Asterisk for the first time. Type this as root....

#asterisk -vvvcf
6) Setup Festival

I compiled this by hand. If there's an easier way I'm all ears. If someone has a deb premade, let me
know. If I ever get a few hours, I'll make one.

I used the steps at http://www.voip-info.org/tiki-
index.php?page=Asterisk%20festival%20installation

wget http://festvox.org/packed/festival/1.4.3/festival-1.4.3-release.tar.gz
wget http://festvox.org/packed/festival/1.4.3/festlex_CMU.tar.gz
wget http://festvox.org/packed/festival/1.4.3/festlex_POSLEX.tar.gz
wget http://festvox.org/packed/festival/1.4.3/festvox_kallpc16k.tar.gz
wget http://festvox.org/packed/festival/1.4.3/speech_tools-1.2.3-release.tar.gz
cd /usr/src ; assumes the downloaded files are located here
tar xvzf speech_tools-1.2.3-release.tar.gz
cd speech_tools
./configure
make
Netweb Confidential                          Page 22                                Property of Netweb Group, Inc.
                                                                                 netweb Group, Inc.
                                                                                 385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                 Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                  We are your one source for VOIP and Broadband


cd ..
tar xvzf festival-1.4.3-release.tar.gz
tar xvzf festlex_CMU.tar.gz
tar xvzf festlex_POSLEX.tar.gz
tar xvzf festvox_kallpc16k.tar.gz
mv festival festival-1.4.3
patch -p0 < festival festival-1.4.3 #mv sys) your on is patch the wherever (or
festival-1.4.3-diff asterisk src>

7) Setup mpg123

I used the Redhat package mentioned at

http://www.voip-info.org/tiki-index.php?page=Asterisk+mpg123+redhat

apt-get install rpm
mkdir /var/lib/rpm
wget http://www.mpg123.de/mpg123/precompiled/mpg123-0.59q-1.i386.rpm
rpm -i -nodeps mpg123-0.59r-1.i386.rpm

8) Install extra asterisk goodies.

I use these packages, you may find them useful too.

cvs checkout asterisk-sounds
cvs checkout asterisk-addons


9) Configure Asterisk to Taste

This is not a 1 day project. Learning about contexts is important. I've read the

Asterisk Handbook about 5 times and I still learn something new everytime.

10) Setup Asterisk for auto restart.

I am starting asterisk by doing this in /etc/inittab

ax:2345:respawn:/usr/sbin/asterisk -vvvcf


Billing
We need to install Billing for Asterisk. The steps to follow is as under:
1) Install MySql database server on our Fedora Server
2) Billing System can be downloaded from here:

     http://www.voip-info.org/wiki-Asterisk+billing

Asterisk can store Call Detail Records (CDRs ) in a MySQL database, as an alternative to CSV text files and other database formats.
We need to store the call detail records to our MySql database. The code to do this task of saving the CDRs to the database is as
under:
Netweb Confidential                                        Page 23                                 Property of Netweb Group, Inc.
                                                                                       netweb Group, Inc.
                                                                                       385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                       Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                        We are your one source for VOIP and Broadband


http://www.voip-info.org/wiki-Asterisk+cdr+mysql

CDR Format to store can be seen here:
http://www.csoft.co.uk/cs/services/its_arrived/cdr1.htm

GUI Tools:
    1. Asterisk Manager:

The Asterisk Manager is a client/server model over TCP. Asterisk manager API can be downloaded from below:
    http://www.voip-info.org/wiki-Asterisk+manager+API

     2.    Click to Call:

           Very Important Application for us. It uses TACI (Trivial Asterisk Call-generator Interface)
           http://www.azxws.com/asterisk/

           It uses a Perl CGI script to make a call (currently SIP, IAX, & ZAP) from a web-page. It Uses the Asterisk manager
           API
Mangement communication consists of tags of the form “header: value”, terminated with an empty newline (\r\n) in the style of SMTP,
HTTP, and other headers.

The first tag MUST be one of the following:
•          Action: An action requested by the CLIENT to the Asterisk SERVER. Only one “Action”
           may be outstanding at any time.
•          Response: A response to an action from the Asterisk SERVER to the CLIENT.
•          Event: An event reported by the Asterisk SERVER to the CLIENT

Management users are configured in /etc/asterisk/manager.conf and are given permissions for read and write, where write
represents their ability to perform this class of “action”, and read represents their ability to receive this class of “event”.


Speech Tools:
    1. Asterisk Festival – A text to Speech Conversion and Synthesis Tool. This is extremely useful for writing clean scripts for
        Asterisk. Festival is a general multi-lingual speech synthesis system developed at CSTR. It offers a full text to speech
        system with various APIs, as well an environment for development and research of speech synthesis techniques. It is
        written in C++ with a Scheme-based command interpreter for general control.

http://www.voip-info.org/wiki-Asterisk+festival+installation

     2.    SOX – Wave to GSM File Conversion Tool:

There is an add-on Wave File Conversion Tool named SOX available. Converting your WAV files to good GSM files is easier than
you might think if you have the program Sox installed.

SOX source is now available at: http://sox.sourceforge.net/

From the shell prompt, enter this command http://www.voip-info.org/wiki-Sox

Convertion Syntax for the Wave Files to SOX is below:



Netweb Confidential                                        Page 24                                       Property of Netweb Group, Inc.
                                                                                   netweb Group, Inc.
                                                                                   385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                   Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                    We are your one source for VOIP and Broadband




Convert WAV audio files for use in Asterisk

Converting your WAV files to good GSM files is easier than you might think if you have the program Sox installed. From the shell
prompt, enter this command:

sox foo.wav -r 8000 foo.gsm resample -ql

and hit the <ENTER> key. In a few moments you will have a new GSM format file in the same directory as the original WAV file. In
this example “foo.wav” is your main voice menu audio file in WAV format, and “foo.gsm” is the same file converted to GSM format. If
you wanted to, you could use “main-voice-menu.gsm” as the name in place of “foo.gsm”: what matters here is the second file name
you use in this command ends in “.gsm”.

If you have multiple WAV files in one directory and you want to convert them all, use this command:

  for a in *.wav;
     do sox $a -r 8000 ‘echo $a|sed -e s/wav//‘gsm resample -ql;
     done




Netweb Confidential                                     Page 25                                      Property of Netweb Group, Inc.
                                                                                         netweb Group, Inc.
                                                                                         385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                         Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                          We are your one source for VOIP and Broadband


Asterisk Commands:
Answer-Answer - Answer a channel if ringing
Answer(): If the channel is ringing, answer it, otherwise do nothing. Returns 0 unless it tries to answer the channel and fails.

Goto -Goto - Goto a particular priority, extension, or context
Goto([[context|]extension|]priority): Set the priority to the specified value, optionally setting the extension and optionally the context as
well. The extension BYEXTENSION is special in that it uses the current extension, thus permitting you to go to a different context,
without specifying a specific extension. Always returns 0, even if the given context, extension, or priority is invalid.

Hangup
Hangup - Unconditional hangup
Hangup(): Unconditionally hangs up a given channel by returning -1 always.

DigitTimeout
DigitTimeout - Set maximum timeout between digits
DigitTimeout(seconds): Set the maximum amount of time permitted between digits when the user is typing in an extension. When this
timeout expires, after the user has started to type in an extension, the extension will be considered complete, and will be interpreted.
Note that if an extension typed in is valid, it will not have to timeout to be tested, so typically at the expiry of this timeout, the extension
will be considered invalid (and thus control would be passed to the 'i' extension, or if it doesn't exist the call would be terminated).
Always returns 0.

ResponseTimeout
ResponseTimeout - Set maximum timeout awaiting response
ResponseTimeout(seconds): Set the maximum amount of time permitted after falling through a series of priorities for a channel in
which the user may begin typing an extension. If the user does not type an extension in this amount of time, control will pass to the 't'
extension if it exists, and if not the call would be terminated. Always returns 0.

AbsoluteTimeout
AbsoluteTimeout - Set absolute maximum time of call
AbsoluteTimeout(seconds): Set the absolute maximum amount of time permitted for a call. A setting of 0 disables the timeout. Always
returns 0.

BackGround
BackGround - Play a file while awaiting extension
Background(filename): Plays a given file, while simultaneously waiting for the user to begin typing an extension. The timeouts do not
count until the last BackGround application as ended. Always returns 0.

Wait
Wait - Waits for some time
Wait(seconds): Waits for a specified number of seconds, then returns 0.

StripMSD
StripMSD - Strip leading digits
StripMSD(count): Strips the leading 'count' digits from the channel's associated extension. For example, the number 5551212 when
stripped with a count of 3 would be changed to 1212. This app always returns 0, and the PBX will continue processing at the next
priority for the *new* extension. So, for example, if priority 3 of 5551212 is StripMSD 3, the next step executed will be priority 4 of
1212. If you switch into an extension which has no first step, the PBX will treat it as though the user dialed an invalid extension.

Prefix
Prefix - Prepend leading digits
Prefix(digits): Prepends the digit string specified by digits to the channel's associated extension. For example, the number 1212 when
prefixed with '555' will become 5551212. This app always returns 0, and the PBX will continue processing at the next priority for the
*new* extension. So, for example, if priority 3 of 1212 is Prefix 555, the next step executed will be priority 4 of 5551212. If you switch
into an extension which has no first step, the PBX will treat it as though the user dialed an invalid extension.
Netweb Confidential                                         Page 26                                        Property of Netweb Group, Inc.
                                                                                       netweb Group, Inc.
                                                                                       385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                       Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                        We are your one source for VOIP and Broadband




SetLanguage
SetLanguage - Sets user language
SetLanguage(language): Set the channel language to 'language'. This information is used for the generation of numbers, and to select
a natural language file when available. For example, if language is set to 'fr' and the file 'demo-congrats' is requested to be played, if
the file 'demo- congrats-fr' exists, then it will play that file, and if not will play the normal 'demo-congrats'. Always returns 0.

Ringing
Ringing - Indicate ringing tone
Ringing(): Request that the channel indicate ringing tone to the user. Always returns 0.

Congestion
Congestion - Indicate congestion and stop
Congestion(): Requests that the channel indicate congestion and then waits for the user to hang up. Always returns -1.

Busy
Busy - Indicate busy condition and stop
Busy(): Requests that the channel indicate busy condition and then waits for the user to hang up. Always returns -1.

SetVar
SetVar - Set variable to value
Setvar(#n=value): Sets variable n to value

SetGlobalVar
SetGlobalVar - Set variable to value
Setvar(#n=value): Sets global variable n to value

NoOp
NoOp - No operation
NoOp(): No-operation; Does nothing.

GotoIf
GotoIf - Conditional goto
GotoIf(Condition?label1:label2): Go to label 1 if condition is true, to label2 if condition is false. Either label1 or label2 may be omitted
(in that case, we just don't take the particular branch) but not both. Look for the condition syntax in examples or documentation.

ADSIProg
Asterisk ADSI Programming Application - Load Asterisk ADSI Scripts into phone
ADSIProg(script): Programs an ADSI Phone with the given script. If none is specified, the default is used. Returns 0 unless CPE is
hungup.

AGI
Asterisk Gateway Interface (AGI) - Executes an AGI compliant application
[E]AGI(command|args): Executes an Asterisk Gateway Interface compliant program on a channel. AGI allows Asterisk to launch
external programs written in any language to control a telephony channel, play audio, read DTMF digits, etc. by communicating with
the AGI protocol on stdin and stdout. Returns -1 on hangup or if application requested hangup, or 0 on non-hangup exit. Using 'EAGI'
provides enhanced AGI, with audio available out of band on file descriptor 3

Authenticate
Authentication Application - Authenticate a user
Authenticate(password[|options]): Requires a user to enter a given password in order to continue execution. If the password begins
with the '/' character, it is interpreted as a file which contains a list of valid passwords (1 per line). an optional set of opions may be
provided by concatenating any of the following letters:
a - Set account code to the password that is entered
Netweb Confidential                                       Page 27                                        Property of Netweb Group, Inc.
                                                                                       netweb Group, Inc.
                                                                                       385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                       Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                        We are your one source for VOIP and Broadband


Returns 0 if the user enters a valid password within three tries, or -1 otherwise (or on hangup).


ChanIsAvail
Check if channel is available - Check if channel is available
ChanIsAvail(Technology/resource[&Technology2/resource2...]): Checks is any of the requested channels are available. If none of the
requested channels are available the new priority will be n+101 (unless such a priority does not exist, in which case ChanIsAvail will
return -1. If any of the requested channels are available, the next priority will be n+1, the channel variable ${CHANAVAIL} will be set
to the name of the available channel and the ChanIsAvail app will return 0.

DateTime
Date and Time - Say the date and time
DateTime(): Says the current date and time. Returns -1 on hangup or 0 otherwise.

DBget
Database access functions for Asterisk extension logic - Retrieve a value from the database
DBget(varname=family/key): Retrieves a value from the Asterisk database and stores it in the given variable. Always returns 0. If the
requested key is not found, jumps to priority n+101 if available.

DBput
Database access functions for Asterisk extension logic - Store a value in the database
DBput(family/key=value): Stores the given value in the Asterisk database. Always returns 0.

DBdel
Database access functions for Asterisk extension logic - Delete a key from the database
DBdel(family/key): Deletes a key from the Asterisk database. Always returns 0.

DBdeltree
Database access functions for Asterisk extension logic - Delete a family or keytree from the database
DBdeltree(family[/keytree]): Deletes a family or keytree from the Asterisk database. Always returns 0.

Dial
Dialing Application - Place an call and connect to the current channel
Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]): Requests one or more channels and places specified
outgoing calls on them. As soon as a channel answers, the Dial app will answer the originating channel (if it needs to be answered)
and will bridge a call with the channel which first answered. All other calls placed by the Dial app will be hunp up If a timeout is not
specified, the Dial application will wait indefinitely until either one of the called channels answers, the user hangs up, or all channels
return busy or error. In general, the dialler will return 0 if it was unable to place the call, or the timeout expired. However, if all
channels were busy, and there exists an extension with priority n+101 (where n is the priority of the dialler instance), then it will be the
next executed extension (this allows you to setup different behavior on busy from no-answer). This application returns -1 if the
originating channel hangs up, or if the call is bridged and either of the parties in the bridge terminate the call. The option string may
contain zero or more of the following characters:
't' -- allow the called user transfer the calling user

'T' -- to allow the calling user to transfer the call.

'r' -- indicate ringing to the calling party, pass no audio until answered.

'm' -- provide hold music to the calling party until answered.

'd' -- data-quality (modem) call (minimum delay).

'c' -- clear-channel data call (PRI-PRI only).

Netweb Confidential                                         Page 28                                      Property of Netweb Group, Inc.
                                                                                       netweb Group, Inc.
                                                                                       385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                       Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                        We are your one source for VOIP and Broadband


'H' -- allow caller to hang up by hitting *.

'C' -- reset call detail record for this call.

'P[(x)]' -- privacy mode, using 'x' as database if provided.
In addition to transferring the call, a call may be parked and then picked up by another user. The optionnal URL will be sent to the
called party if the channel supports it.


Directory
Extension Directory - Provide directory of voicemail extensions
Directory(context): Presents the user with a directory of extensions from which they may select by name. The list of names and
extensions is discovered from voicemail.conf. The context argument is required, and specifies the context in which to interpret the
extensions. Returns 0 unless the user hangs up. It also sets up the channel on exit to enter the extension the user selected.

DISA
DISA (Direct Inward System Access) Application - DISA (Direct Inward System Access)
DISA (Direct Inward System Access) -- Allows someone from outside the telephone switch (PBX) to obtain an "internal" system
dialtone and to place calls from it as if they were placing a call from within the switch. A user calls a number that connects to the DISA
application and is given dialtone. The user enters their passcode, followed by the pound sign (#). If the passcode is correct, the user is
then given system dialtone on which a call may be placed. Obviously, this type of access has SERIOUS security implications, and
GREAT care must be taken NOT to compromise your security.
There is a possibility of accessing DISA without password. Simply exchange your password with no-password.

Example: exten => s,1,DISA,no-password|local

but be aware of using this for your security compromising.

The arguments to this application (in extensions.conf) allow either specification of a single global password (that everyone uses), or
individual passwords contained in a file. It also allow specification of the context on which the user will be dialing. If no context is
specified, the DISA application defaults the context to "disa" presumably that a normal system will have a special context set up for
DISA use with some or a lot of restrictions. The arguments are one of the following:

numeric-passcode numeric-passcode|context full-pathname-of-file-that-contains-passcodes

The file that contains the passcodes (if used) allows specification of either just a passcode (defaulting to the "disa" context, or
passcode|context on each line of the file. The file may contain blank lines, or comments starting with "#" or ";". In addition, the above
arguments may have |new-callerid-string appended to them, to specify a new (different) callerid to be used for this call, for

example: numeric-passcode|context|"My Phone" <(234) 123-4567> or full-pathname-of-passcode-file|"My Phone" <(234) 123-4567>.
Note that in the case of specifying the numeric-passcode, the context must be specified if the callerid is specified also.
If login is successful, the application parses the dialed number in the specified (or default) context, and returns 0 with the new
extension context filled-in and the priority set to 1, so that the PBX may re-apply the routing tables to it and complete the call normally.


Echo
Simple Echo Application - Echo audio read back to the user
Echo(): Echo audio read from channel back to the channel. Returns 0 if the user exits with the '#' key, or -1 if the user hangs up.

Festival
Simple Festival Interface - Say text to the user
Festival(): Connect to Festival, send the argument, get back the waveform, play it to the user.

Flash
Netweb Confidential                                       Page 29                                        Property of Netweb Group, Inc.
                                                                                       netweb Group, Inc.
                                                                                       385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                       Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                        We are your one source for VOIP and Broadband


Flash zap trunk application - Flashes a Zap Trunk
Flash(): Sends a flash on a zap trunk. This is only a hack for people who want to perform transfers and such via AGI and is generally
quite useless otherwise. Returns 0 on success or -1 if this is not a zap trunk

GetCPEID
Get ADSI CPE ID - Get ADSI CPE ID
GetCPEID: Obtains and displays CPE ID and other information in order to properly setup zapata.conf for on-hook operations. Returns
-1 on hangup only.

SendImage
Image Transmission Application - Send an image file
SendImage(filename): Sends an image on a channel. If the channel does not support image transport, and there exists a step with
priority n + 101, then execution will continue at that step. Otherwise, execution will continue at the next priority level. SendImage only
returns 0 if the image was sent correctly or if the channel does not support image transport, and -1 otherwise.

Intercom
Intercom using /dev/dsp for output - (Obsolete) Send to Intercom
Intercom(): Sends the user to the intercom (i.e. /dev/dsp). This program is generally considered obselete by the chan_oss module.
Returns 0 if the user exits with a DTMF tone, or -1 if they hangup.

LookupBlacklist
Look up Caller*ID name/number from blacklist database - Look up Caller*ID name/number from blacklist database
LookupBlacklist: Looks up the Caller*ID number on the active channel in the Asterisk database (family 'blacklist'). If the number is
found, and if there exists a priority n + 101, where 'n' is the priority of the current instance, then the channel will be setup to continue
at that priority level. Otherwise, it returns 0. Does nothing if no Caller*ID was received on the channel.
Example: database put blacklist <name/number> 1


LookupCIDName
Look up CallerID Name from local database - Look up CallerID Name from local database
LookupCIDName: Looks up the Caller*ID number on the active channel in the Asterisk database (family 'cidname') and sets the
Caller*ID name. Does nothing if no Caller*ID was received on the channel. This is useful if you do not subscribe to Caller*ID name
delivery, or if you want to change the names on some incoming calls. Always returns 0.

Macro
Extension Macros - Macro Implementation
Macro(macroname|arg1|arg2...): Executes a macro using the context 'macro-<macroname>', jumping to the 's' extension of that
context and executing each step, then returning when the steps end. The calling extension, context, and priority are stored in
${MACRO_EXTEN}, ${MACRO_CONTEXT} and ${MACRO_PRIORITY} respectively. Arguments become ${ARG1}, ${ARG2}, etc in
the macro context. Macro returns -1 if any step in the macro returns -1, and 0 otherwise. If you Goto out of the Macro context, the
Macro will terminate and control will be return at the location of the Goto. Otherwise if ${MACRO_OFFSET} is set at termination,
Macro will attempt to continue at priority MACRO_OFFSET + N + 1 if such a step exists, and N + 1 otherwise.

MeetMe
Simple MeetMe conference bridge - Simple MeetMe conference bridge
MeetMe(confno[|options]): Enters the user into a specified MeetMe conference. If the conference number is omitted, the user will be
prompted to enter one. This application always returns -1. A ZAPTEL INTERFACE MUST BE INSTALLED FOR CONFERENCING
FUNCTIONALITY. The option string may contain zero or more of the following characters:
'a' -- set admin mode

'm' -- set monitor only mode

'p' -- allow user to exit the conference by pressing '#'

Netweb Confidential                                        Page 30                                       Property of Netweb Group, Inc.
                                                                                        netweb Group, Inc.
                                                                                        385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                        Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                         We are your one source for VOIP and Broadband


's' -- send user to admin/user menu if '*' is received

't' -- set talk only mode

'q' -- quiet mode (don't play enter/leave sounds)



Milliwatt
Digital Milliwatt (mu-law) Test Application - Generate a Constant 1000Hz tone at 0dbm (mu-law)
Milliwatt(): Generate a Constant 1000Hz tone at 0dbm (mu-law)

MP3Player
Silly MP3 Application - Play an MP3 file or stream
MP3Player(location) Executes mpg123 to play the given location which typically would be a filename or a URL. Returns -1 on hangup
or 0 otherwise. User can exit by pressing any key.

ParkAndAnnounce
Call Parking and Announce Application - Park and Announce
ParkAndAnnounce(announce:template|timeout|dial|[return_context]): Park a call into the parkinglot and announce the call over the
console.
announce template: colon seperated list of files to announce, the word PARKED will be replaced by a say_digits of the ext the call is
parked in

timeout: time in seconds before the call returns into the return context.
dial: The app_dial style resource to call to make the announcement. Console/dsp calls the console.
return_context: the goto style label to jump the call back into after timeout. default=prio+1


Playback
Trivial Playback Application - Play a file
Playback(filename[|option]): Plays back a given filename (do not put extension). Options may also be included following a pipe
symbol. The only defined option at this time is 'skip', which causes the playback of the message to be skipped if the channel is not in
the 'up' state (i.e. it hasn't been answered yet. If 'skip' is specified, the application will return immediately should the channel not be off
hook. Otherwise, unless 'noanswer' is specified, the channel channel will be answered before the sound is played. Not all channels
support playing messages while on hook. Returns -1 if the channel was hung up, or if the file does not exist. Returns 0 otherwise.

PrivacyManager
Require phone number to be entered, if no CallerID sent - Require phone number to be entered, if no CallerID sent
PrivacyManager: If no Caller*ID is sent, PrivacyManager answers the channel and asks the caller to enter their 10 digit phone
number. The caller is given 3 attempts. If after 3 attempts, they do no enter their 10 digit phone number, and if there exists a priority n
+ 101, where 'n' is the priority of the current instance, then the channel will be setup to continue at that priority level. Otherwise, it
returns 0. Does nothing if Caller*ID was received on the channel.

Queue
True Call Queueing - Queue a call for a call queue
Queue(queuename[|options[|URL][|announceoverride]]): Queues an incoming call in a particular call queue as defined in queues.conf.
This application returns -1 if the originating channel hangs up, or if the call is bridged and either of the parties in the bridge terminate
the call. Returns 0 if the queue is full, nonexistant, or has no members. The option string may contain zero or more of the following
characters:
't' -- allow the called user transfer the calling user

'T' -- to allow the calling user to transfer the call.

Netweb Confidential                                         Page 31                                       Property of Netweb Group, Inc.
                                                                                        netweb Group, Inc.
                                                                                        385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                        Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                         We are your one source for VOIP and Broadband


'd' -- data-quality (modem) call (minimum delay).

'H' -- allow caller to hang up by hitting *.
In addition to transferring the call, a call may be parked and then picked up by another user. The optionnal URL will be sent to the
called party if the channel supports it.


Random
Random goto -


Record
Trivial Record Application - Record to a file
Record(filename:extension): Records from the channel into a given filename. If the file exists it will be overwritten. The 'extension' is
the extension of the file type to be recorded (wav, gsm, etc). Returns -1 when the user hangs up.

SendDTMF
Send DTMF digits Application - Sends arbitrary DTMF digits
SendDTMF(digits): Sends DTMF digits on a channel. Returns 0 on success or -1 on a hangup.

SetCallerID
Set CallerID Application - Set CallerID
SetCallerID(clid[|a]): Set Caller*ID on a call to a new value. Sets ANI as well if a flag is used. Always returns 0

SetCIDName
Set CallerID Name - Set CallerID Name
SetCIDName(cname[|a]): Set Caller*ID Name on a call to a new value, while preserving the original Caller*ID number. This is useful
for providing additional information to the called party. Sets ANI as well if a flag is used. Always returns 0

SoftHangup
Hangs up the requested channel - Soft Hangup Application


PGSQL
Simple PostgreSQL Interface - Do several SQLy things
PGSQL(): Do several SQLy things

StripLSD
Strip trailing digits - Strip Least Significant Digits
StripLSD(count): Strips the trailing 'count' digits from the channel's associated extension. For example, the number 5551212 when
stripped with a count of 4 would be changed to 555. This app always returns 0, and the PBX will continue processing at the next
priority for the *new* extension. So, for example, if priority 3 of 5551212 is StripLSD 4, the next step executed will be priority 4 of 555.
If you switch into an extension which has no first step, the PBX will treat it as though the user dialed an invalid extension.

SubString
Save substring digits in a given variable - Save substring digits in a given variable
StripLSD(variable=string_of_digits|count1|count2): Assigns the substring of string_of_digits to a given variable. Parameter count1 may
be positive or negative. If it's positive then we skip the first count1 digits from the left. If it's negative, we move count1 digits counting
from the end of the string to the left. Parameter count2 may be only positive and implies how many digits we're taking from the point
that count1 placed us. For example: exten => _NXXXXXX,1,SubString,test=2564286161|0|3 assigns the area code (3 first digits) to
variable test. exten => _NXXXXXX,1,SubString,test=2564286161|-7|7 assigns the last 7 digits to variable test. If there are no
parameters it'll return with -1. If there wrong parameters it go on and return with 0

System
Netweb Confidential                                        Page 32                                        Property of Netweb Group, Inc.
                                                                                          netweb Group, Inc.
                                                                                          385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                          Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                           We are your one source for VOIP and Broadband


Generic System() application - Execute a system command
System(command): Executes a command by using system(). Returns -1 on failure to execute the specified command. If the command
itself executes but is in error, and if there exists a priority n + 101, where 'n' is the priority of the current instance, then the channel will
be setup to continue at that priority level. Otherwise, System returns 0.

TimeCondition
Cron-like conditional goto -


SendURL
Send URL Applications - Send a URL
SendURL(URL[|option]): Requests client go to URL. If the client does not support html transport, and there exists a step with priority n
+ 101, then execution will continue at that step. Otherwise, execution will continue at the next priority level. SendURL only returns 0 if
the URL was sent correctly or if the channel does not support HTML transport, and -1 otherwise. If the option 'wait' is specified,
execution will wait for an acknowledgement that the URL has been loaded before continuing and will return -1 if the peer is unable to
load the URL

VoiceMail
Comedian Mail (Voicemail System) - Leave a voicemail message
VoiceMail([s|u|b]extension): Leaves voicemail for a given extension (must be configured in voicemail.conf). If the extension is
preceeded by an 's' then instructions for leaving the message will be skipped. If the extension is preceeded by 'u' then the
"unavailable" message will be played (that is, /var/lib/asterisk/sounds/vm/<exten>/unavail) if it exists. If the extension is preceeded by
a 'b' then the the busy message will be played (that is, busy instead of unavail). At most one of 's', 'u', or 'b' may be specified. Returns
-1 on error or mailbox not found, or if the user hangs up. Otherwise, it returns 0.

VoiceMailMain
Comedian Mail (Voicemail System) - Enter voicemail system
VoiceMailMain(): Enters the main voicemail system for the checking of voicemail. The mailbox can be passed as the option, which will
stop the voicemail system from prompting the user for the mailbox. If the mailbox is preceded by 's' then the password check will be
skipped. Returns -1 if the user hangs up or 0 otherwise.

WaitForRing
Waits until first ring after time - Wait for Ring Application


Zapateller
Block Telemarketers with Special Information Tone - Block telemarketers with SIT
Zapateller(options): Generates special information tone to block telemarketers from calling you. Returns 0 normally or -1 on hangup.
Options is a pipe-delimited list of options. The following options are available: 'answer' causes the line to be answered before playing
the tone, 'nocallerid' causes Zapateller to only play the tone if there is no callerid information available. Options should be separated
by | characters

ZapBarge
Barge in on Zap channel application - Barge in (monitor) Zap channel
ZapBarge([channel]): Barges in on a specified zap channel or prompts if one is not specified. Returns -1 when caller user hangs up
and is independent of the state of the channel being monitored.

ZapRAS
Zap RAS Application - Executes Zaptel ISDN RAS application
ZapRAS(args): Executes a RAS server using pppd on the given channel. The channel must be a clear channel (i.e. PRI source) and a
Zaptel channel to be able to use this function (No modem emulcation is included). Your pppd must be patched to be zaptel aware.
Arguments should be separated by | characters. Always returns -1.


Netweb Confidential                                             Page 33                                     Property of Netweb Group, Inc.
                                                                                  netweb Group, Inc.
                                                                                  385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                  Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                   We are your one source for VOIP and Broadband


The Asterisk command line interface (CLI) is reached by using the Linux shell command

asterisk -r

If you want debugging output, add one or many v:s

asterisk -vvvvvr

The Asterisk server has to be running in the background for the CLI to start. If you want to run a CLI command in a shell script, use
the x option

 asterisk -rx”logger reload”

For help in the CLI mode, use the help command. To get help on various applications you can use in the extensions.conf config file,
use the show applications command.

General commands for Asterisk Command Line

•          !<command>: Executes a given shell command
•          abort halt: Cancel a running halt
•          add extension: Add new extension into context
•          add ignorepat: Add new ignore pattern
•          add indication: Add the given indication to the country
•          debug channel: Enable debugging on a channel
•          dont include: Remove a specified include from context
•          help: Display help list, or specific help on a command
•          include context: Include context in other context
•          load: Load a dynamic module by name
•          logger reload?: Reopen log files. Use after rotating the log files.
•          no debug channel: Disable debugging on a channel
•          pri debug span: Enables PRI debugging on a span
•          pri intense debug span: Enables REALLY INTENSE PRI debugging
•          pri no debug span: Disables PRI debugging on a span
•          remove extension: Remove a specified extension
•          remove ignorepat: Remove ignore pattern from context
•          remove indication: Remove the given indication from the country
•          save dialplan: Overwrites your current extensions.conf file with an exported version
           based on the current state of the dialplan. A backup copy of your old extensions.conf is
           not saved. The initial values of global variables defined in the [globals] category retain
           their previous initial values; the current values of global variables are not written into
           the new extensions.conf. Using “save dialplan” will result in losing any comments in
           your current extensions.conf.
•          set verbose: Set level of verboseness
•          show agents: Show status of agents
•          show applications: Shows registered applications
•          show application: Describe a specific application
•          show channel: Display information on a specific channel
•          show channels: Display information on channels
•          show codecs: Display information on codecs
•          show conferences: Show status of conferences?
•          show dialplan: Show dialplan
•          show image formats: Displays image formats
Netweb Confidential                                     Page 34                                     Property of Netweb Group, Inc.
                                                                    netweb Group, Inc.
                                                                    385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                    Ph: 732-213-2422: email: info@netwebgroup.com
                                                                     We are your one source for VOIP and Broadband


•          show indications: Show a list of all country/indications
•          show locals: Show status of local channels
•          show manager command: Show manager commands
•          show manager connect: Show connected manager users
•          show parkedcalls: Lists parked calls
•          show queues: Show status of queues?
•          show switches: Show alternative switches
•          show translation: Display translation matrix
•          soft hangup: Request a hangup on a given channel
•          show voicemail users: List defined voicemail boxes
•          show voicemail zones: List zone message formats

Server management

•          restart gracefully: Restart Asterisk gracefully
•          restart now: Restart Asterisk immediately
•          restart when convenient: Restart Asterisk at empty call volume
•          reload: Reload configuration
•          stop gracefully: Gracefully shut down Asterisk
•          stop now: Shut down Asterisk imediately
•          stop when convenient: Shut down Asterisk at empty call volume
•          extensions reload?: Reload extensions and only extensions
•          unload: Unload a dynamic module by name
•          show modules: List modules and info about them
•          show uptime: Show uptime information
•          show version: Display Asterisk version info

AGI commands

•          show agi: Show AGI commands or specific help
•          dump agihtml: Dumps a list of agi command in html format

Database handling commands

•          database        del: Removes database key/value
•          database        deltree: Removes database keytree/values
•          database        get: Gets database value
•          database        put: Adds/updates database value
•          database        show: Shows database contents


IAX Channel commands

•          iax2       debug: Enable IAX debugging
•          iax2       no debug: Disable IAX debugging
•          iax2       set jitter: Sets IAX jitter buffer
•          iax2       show cache: Display IAX cached dialplan
•          iax2       show channels: Show active IAX channels
•          iax2       show peers: Show defined IAX peers
•          iax2       show registry: Show IAX registration status
•          iax2       show stats: Display IAX statistics
•          iax2       show users: Show defined IAX users
Netweb Confidential                             Page 35                               Property of Netweb Group, Inc.
                                                                  netweb Group, Inc.
                                                                  385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                  Ph: 732-213-2422: email: info@netwebgroup.com
                                                                   We are your one source for VOIP and Broadband


•          iax2 trunk debug: Request IAX trunk debug
•          iax debug: Enable IAX debugging
•          iax no debug: Disable IAX debugging
•          iax set jitter: Sets IAX jitter buffer
•          iax show cache: Display IAX cached dialplan
•          iax show channels: Show active IAX channels
•          iax show peers: Show defined IAX peers
•          iax show registry: Show IAX registration status
•          iax show stats: Display IAX statistics
•          iax show users: Show defined IAX users
•          init keys: Initialize RSA key passcodes
•          show keys: Displays RSA key information

H323 channel commands

•          h.323      debug: Enable chan_h323 debug
•          h.323      gk cycle: Manually re-register with the Gatekeper
•          h.323      hangup: Manually try to hang up a call
•          h.323      no debug: Disable chan_h323 debug
•          h.323      no trace: Disable H.323 Stack Tracing
•          h.323      show codecs: Show enabled codecs
•          h.323      show tokens: Manually try to hang up a call
•          h.323      trace: Enable H.323 Stack Tracing

SIP channel commands

•          sip debug: Enable SIP debugging
•          sip no debug: Disable SIP debugging
•          sip reload: Reload sip.conf (added after 0.7.1 on 2004-01-23)
•          sip show channels: Show active SIP channels
•          sip show channel: Show detailed SIP channel info
•          sip show inuse: List all inuse/limit
•          sip show peers: Show defined SIP peers (clients that register to your Asterisk server)
•          sip show registry: Show SIP registration status (when Asterisk registers as a client to
           a SIP Proxy)
•          sip show users: Show defined SIP users

Zap channel commands

•          zap destroy channel: Destroy a channel
•          zap show channels: Show active zapata channels
•          zap show channel: Show information on a channel

MGCP channel? commands

•          mgcp       audit endpoint: Audit specified MGCP endpoint
•          mgcp       debug: Enable MGCP debugging
•          mgcp       no debug: Disable MGCP debugging
•          mgcp       show endpoints: Show defined MGCP endpoints



Netweb Confidential                            Page 36                              Property of Netweb Group, Inc.
                                                                                    netweb Group, Inc.
                                                                                    385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                    Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                     We are your one source for VOIP and Broadband


skinny channel? commands

•          skinny debug: Enable Skinny debugging
•          skinny no debug: Disable Skinny debugging
•          skinny show lines: Show defined Skinny lines per device

CAPI channel? commands

•          capi debug: Enable CAPI debugging
•          capi no debug: Disable CAPI debugging
•          capi info: Show CAPI info


Asterisk Dialplan Commands
Here is a list of all the commands that you can use in your Dialplan (extensions.conf). You can obtain your Asterisk’s list of available
applications at the CLI by typing “show applications” and “show appliaction <name>”.


Note: An alphabetical list can be found at the end of this page


General commands
•          ADSIProg: Load Asterisk ADSI Scripts into phone
•          Authenticate: Authenticate a user
•          ChangeMonitor: Change monitoring filename of a channel
•          GetCPEID: Get ADSI CPE ID
•          SendDTMF: Sends arbitrary DTMF digits
•          SendImage: Send an image file
•          SendText: Send client a text message
•          SendURL: Send a client a URL? to display
•          System: Execute a system command
•          Transfer: Transfer caller to remote extension
•          Wait: Waits for some time
•          WaitExten: Waits for some time
•          WaitForRing: Wait for Ring Application
•          WaitMusicOnHold: Wait, playing Music On Hold
Billing
•          NoCDR: Make sure asterisk doesn’t save CDR for a certain call
•          ResetCDR: Reset CDR data
•          SetAccount: Sets account code
•          SetCDRUserField: Set CDR User field
•          AppendCDRUserField: Append data to CDR User field
Call management (hangup, answer, dial, etc)
•          Answer: Answer a channel if ringing
•          Busy: Indicate busy condition and wait for hangup
•          ChanIsAvail: Check if channel is available
•          Congestion: Indicate congestion and wait for hangup
•          Dial: Place an call and connect to the current channel
•          DISA: DISA (Direct Inward System Access)
Netweb Confidential                                      Page 37                                      Property of Netweb Group, Inc.
                                                                  netweb Group, Inc.
                                                                  385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                  Ph: 732-213-2422: email: info@netwebgroup.com
                                                                   We are your one source for VOIP and Broadband


•          Hangup: Unconditional hangup
Caller presentation (ID, Name etc)
•          CallingPres: Change the presentation for the callerid
•          LookupBlacklist: Look up Caller*ID name/number from blacklist database
•          LookupCIDName: Look up CallerID Name from local database
•          PrivacyManager: Require phone number to be entered, if no CallerID sent
•          Ringing: Indicate ringing tone
•          SetCallerID: Set CallerID
•          SetCIDName: Set CallerID Name?
•          SoftHangup: Request hangup on another channel
•          Zapateller: Block telemarketers with SIT
Database handling
•          DBdel: Delete a key from the database
•          DBdeltree: Delete a family or keytree from the database
•          DBget: Retrieve a value from the database
•          DBput: Store a value in the database

See Asterisk database for more information.


Application integration
•          AGI: Executes an AGI compliant application
•          DeadAGI: Executes AGI on a hung-up channel
•          EAGI: Executes an AGI compliant application
•          EnumLookup: Lookup number in ENUM
•          Macro: Macro Implementation
•          NoOp: No operation. Can print values to console for debugging.
•          Read: Read a variable with DTMF
•          TXTCIDName: Lookup caller name from TXT record
Control flow & timeouts
•          AbsoluteTimeout: Set absolute maximum time of call
•          DigitTimeout: Set maximum timeout between digits
•          Goto: Goto a particular priority, extension, or context
•          GotoIf: Conditional goto
•          GotoIfTime: Conditional goto on current time
•          Random: Make a random jump in your dial plan
•          ResponseTimeout: Set maximum timeout awaiting response
String & variable manipulation
•          Cut: String handling function
•          Prefix: Prepend leading digits (Obsolete)
•          SetGlobalVar: Set variable to value
•          SetVar: Set variable to value
•          StripLSD: Strip trailing digits
•          StripMSD: Strip leading digits (Obsolete)
•          SubString: Save substring digits in a given variable (Obsolete)
•          Suffix: Append trailing digits (Obsolete)


Netweb Confidential                           Page 38                               Property of Netweb Group, Inc.
                                                                               netweb Group, Inc.
                                                                               385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                               Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                We are your one source for VOIP and Broadband


Sounds: Playing and Recording
•        Playback: Play a sound file
•        ControlPlayback: Play a sound file with fast forward, rewind and exit controls
•        MP3Player: Play an MP3 sound file or stream
•        Background: Play a sound file while executing other commands
•        Playtones: Play a tone list while executing other commands
•        StopPlaytones: Stop playing a tone list
•        Festival: Say text with the Festival voice synthesizer
•        SayUnixTime: Say the date and/or time
•        DateTime: Say the date and/or time (Obsolete)
•        SayAlpha: Say Alpha
•        SayDigits: Say Digits
•        SayNumber: Say Number
•        SayPhonetic: Say Phonetic
•        Record: Record a telephone conversation to a sound file
•        Monitor: Record a telephone conversation to a sound file
•        ChangeMonitor: Change monitoring filename of a channel
•        StopMonitor: Stop monitoring a channel
•        MusicOnHold: Play Music On Hold indefinitely
•        SetMusicOnHold: Set default Music On Hold class
•        Echo: Echo audio read back to the user
•        Milliwatt: Generate a Constant 1000Hz tone at 0dbm (mu-law)
•        SetLanguage: Change language setting for sound playback
See Asterisk sound files for more information.

SIP commands
•          SIPdtmfMode: Change DTMF mode during SIP call
ZAP commands
•        Flash: Flashes a Zap Trunk
•        ZapBarge: Barge in (monitor) Zap channel
•        ZapRAS: Provide ISDN data service
•        ZapScan?: Scan Zap channels to monitor calls
See Asterisk zap channels, zapata.conf for more information.

Voicemail and conferencing
•         Directory: Provide directory of voicemail extensions
•         HasNewVoicemail: Conditionally branches to priority + 101
•         MailboxExists: Checks if mailbox exists
•         MeetMe: Simple MeetMe conference bridge
•         MeetMeCount: MeetMe participant count
•         VoiceMail: Leave a voicemail message
•         VoiceMailMain: Enter voicemail system
•         Old: VoiceMail2: Leave a voicemail message
•         Old: VoiceMailMain2: Enter voicemail system
See voicemail.conf for more information. VoiceMail, version 1 is now replaced with VoiceMail version 2 so all voicemail commands
leads to voicemail version 2.
Queue and ACD management
•          AddQueueMember: Dynamically adds queue members
Netweb Confidential                                  Page 39                                     Property of Netweb Group, Inc.
                                                                    netweb Group, Inc.
                                                                    385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                    Ph: 732-213-2422: email: info@netwebgroup.com
                                                                     We are your one source for VOIP and Broadband


•          AgentCallbackLogin: Call agent callback login
•          AgentLogin: Call agent login
•          AgentMonitorOutgoing: Record agent’s outgoing call
•          ParkAndAnnounce: Park and Announce
•          ParkedCall: Answer a parked call
•          Queue: Queue a call for a call queue
•          RemoveQueueMember: Dynamically removes queue members
External applications (not in the CVS)
•          Asterisk app_dbodbc: Dialplan modifiers using unixODBC
•          DynExtenDB: Store extensions in database
•          app Prepaid: Designed for Postgres

Alphabetical list
•          AbsoluteTimeout: Set absolute maximum time of call
•          AddQueueMember: Dynamically adds queue members
•          ADSIProg: Load Asterisk ADSI Scripts into phone
•          AgentCallbackLogin: Call agent callback login
•          AgentLogin: Call agent login
•          AgentMonitorOutgoing: Monitor Outgoing Agent Calls (0.7.3)
•          AGI: Executes an AGI compliant application
•          Answer: Answer a channel if ringing
•          AppendCDRUserField: Append data to the CDR user field
•          Authenticate: Authenticate a user
•          BackGround: Play a file while awaiting extension
•          Busy: Indicate busy condition and wait for hangup
•          CallingPres: Change the presentation for the callerid in a ZAP channel
•          ChangeMonitor: Change monitoring filename of a channel
•          ChanIsAvail: Check if channel is available
•          CheckGroup: checks if the total # of channels exceeds max
•          Congestion: Indicate congestion and wait for hangup
•          ControlPlayback: Play a sound file with fast forward, rewind and exit controls
•          Cut: String handling function
•          DateTime: Say the date and/or time (Obsolete)
•          DBdel: Delete a key from the database
•          DBdeltree: Delete a family or keytree from the database
•          DBget: Retrieve a value from the database
•          DBput: Store a value in the database
•          DeadAGI: Executes AGI on a hungup channel
•          Dial: Place an call and connect to the current channel
•          DigitTimeout: Set maximum timeout between digits
•          Directory: Provide directory of voicemail extensions
•          DISA: DISA (Direct Inward System Access)
•          EAGI?: Executes an AGI compliant application
•          Echo: Echo audio read back to the user
•          EnumLookup: Lookup number in ENUM
•          Eval: Evaluate arguments before calling application
•          Festival: Say text with the Festival voice synthesizer
•          Flash: Flashes a Zap Trunk
•          GetCPEID: Get ADSI CPE ID
•          GetGroupCount?: group count for specified group or channel is in
Netweb Confidential                            Page 40                                Property of Netweb Group, Inc.
                                                                netweb Group, Inc.
                                                                385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                Ph: 732-213-2422: email: info@netwebgroup.com
                                                                 We are your one source for VOIP and Broadband


•          Goto: Goto a particular priority, extension, or context
•          GotoIf: Conditional goto
•          GotoIfTime: Conditional goto on current time
•          Hangup: Unconditional hangup
•          HasNewVoicemail: Conditionally branches to priority + 101
•          HasVoicemail?: Conditionally branches to priority + 101
•          ICES: Streaming calls to the Internet
•          LookupBlacklist: Look up Caller*ID name/number from blacklist database
•          LookupCIDName: Look up CallerID Name from local database
•          Macro: Macro Implementation
•          MailboxExists: Checks if voicemail mailbox exists
•          MeetMe: Simple MeetMe conference bridge
•          MeetMeAdmin?: MeetMe conference Administration
•          MeetMeCount: MeetMe participant count
•          Milliwatt: Generate a constant 1000Hz tone at 0dbm (mu-law)
•          Monitor: Record a telephone conversation to a sound file
•          MP3Player: Play an MP3 sound file or stream
•          MusicOnHold: Play Music On Hold indefinitely
•          NBScat?: Play an NBS local stream
•          NoCDR: Make sure asterisk doesn’t save CDR for a certain call
•          NoOp: No operation. Can print values to console for debugging.
•          ParkAndAnnounce: Park and Announce
•          ParkedCall: Answer a parked call
•          Playback: Play a file
•          Playtones: Play a tone list while executing other commands
•          Prefix: Prepend leading digits
•          PrivacyManager: Require phone number to be entered, if no CallerID sent
•          Queue: Queue a call for a call queue
•          Random: Make a random jump in your dial plan
•          Read: Read a variable
•          Record: Record a telephone conversation to a sound file
•          RemoveQueueMember: Dynamically removes queue members
•          ResetCDR: Reset CDR data
•          ResponseTimeout: Set maximum timeout awaiting response
•          Ringing: Indicate ringing tone
•          SayAlpha: Say Alpha
•          SayDigits: Say Digits
•          SayNumber: Say Number
•          SayPhonetic: Say Phonetic
•          SayUnixTime: Say the date and/or time
•          SendDTMF: Sends arbitrary DTMF digits
•          SendImage: Send an image file
•          SendText: Send client a text message
•          SendURL: Send client a URL? to display
•          SetAccount: Sets account code
•          SetCallerID: Set CallerID
•          SetCDRUserField: Set CDR User Field. See Billing.
•          SetCIDName: Set CallerID Name?
•          SetGlobalVar: Set variable to value
•          SetGroup: Sets the group name on the channel
•          SetLanguage: Change language setting for sound playback
Netweb Confidential                          Page 41                              Property of Netweb Group, Inc.
                                                                                     netweb Group, Inc.
                                                                                     385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                     Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                      We are your one source for VOIP and Broadband


•          SetMusicOnHold: Set default Music On Hold class
•          SetVar: Set variable to value
•          SIPdtmfMode: Change DTMF mode during SIP call
•          SMS: Send and receive SMS (short messaging service)
•          SoftHangup: Soft Hangup Application
•          StopMonitor: Stop monitoring a channel
•          StopPlaytones: Stop playing a tone list
•          StripLSD: Strip least significant digits
•          StripMSD: Strip leading digits
•          SubString: (Obsolete) Save substring digits in a given variable
•          Suffix: Append trailing digits
•          System: Execute a system command
•          Transfer: Transfer caller to remote extension
•          TXTCIDName: Lookup caller name from TXT record
•          VoiceMail: Leave a voicemail message
•          VoiceMail2: (Obsolete) Leave a voicemail message
•          VoiceMailMain: Enter voicemail system
•          VoiceMailMain2: (Obsolete) Enter voicemail system
•          Wait: Waits for some time
•          WaitExten: Waits for some time
•          WaitForRing: Wait for Ring Application
•          WaitMusicOnHold: Wait, playing Music On Hold
•          Zapateller: Block telemarketers with SIT
•          ZapBarge: Barge in (monitor) Zap channel
•          ZapRAS: Provide ISDN data service
•          ZapScan?: Scan Zap channels to monitor calls


AGI Scripting Syntax - Commands in Detail:
DATABASE PUT <family> <key> <value>
Function Adds or updates an entry in the Asterisk database for a given family, key, and value.
Returns 1 if successful
0 otherwise
Notes

DATABASE GET <family> <key>
Function Retrieves an entry in the Asterisk database for a given family and key.
Returns 0 if <key> is not set.
1 if <key> is set and returns the variable in parenthesis
Notes example return code: 200 result=1 (testvariable)

DATABASE DEL <family> <key>
Function Deletes an entry in the Asterisk database for a given family and key.
Returns 1 if successful
0 otherwise
Notes

DATABASE DELTREE <family> [keytree]
Function Deletes a family or specific keytree within a family in the Asterisk database.
Returns 1 if successful
0 otherwise
Notes
Netweb Confidential                                       Page 42                                      Property of Netweb Group, Inc.
                                                                                         netweb Group, Inc.
                                                                                         385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                         Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                          We are your one source for VOIP and Broadband




VERBOSE <message> <level>
Function Sends <message> to the console via verbose message system.
Returns Always returns 1
Notes <level> is the the verbose level (1-4)

GET VARIABLE <variablename>
Function
Returns 0 if <variablename> is not set.
1 if <variablename> is set and returns the variable in parenthesis
Notes example return code: 200 result=1 (testvariable)

SET VARIABLE <variablename> <value>
Function
Returns
Notes

CHANNEL STATUS [<channelname>]
Function Returns the status of the specified channel. If no channel name is given, returns the status of the current channel.
Returns 0 Channel is down and available
1 Channel is down, but reserved
2 Channel is off hook
3 Digits (or equivalent) have been dialed
4 Line is ringing
5 Remote end is ringing
6 Line is up
7 Line is busy
Notes

SET CALLERID <number>
Function Changes the callerid of the current channel.
Returns
Notes

EXEC <application> <options>
Function Executes <application> with given <options>.
Returns Whatever the application returns
-2 on failure to find application
Notes

HANGUP [<channelname>]
Function Hangs up the specified channel. If no channel name is given, hangs up the current channel
Returns
Notes

ANSWER
Function Answers channel if not already in answer state.
Returns -1 on channel failure
0 if successful.
Notes

WAIT FOR DIGIT <timeout>
Function Waits up to 'timeout' milliseconds for channel to receive a DTMF digit.
Returns -1 on channel failure, 0 if no digit is received in the timeout, or the numerical value of the ascii of the digit if one is received.
Netweb Confidential                                         Page 43                                        Property of Netweb Group, Inc.
                                                                                      netweb Group, Inc.
                                                                                      385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                      Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                       We are your one source for VOIP and Broadband


Notes Use -1 for the timeout value if you desire the call to block indefinitely.

SEND TEXT "<text to send>"
Function Sends the given text on a channel. Most channels do not support the transmission of text.
Returns 0 if text is sent, or if the channel does not support text transmission.
-1 only on error/hangup.
Notes Text consisting of greater than one word should be placed in quotes since the command only accepts a single argument.

RECEIVE CHAR <timeout>
Function Receives a character of text on a channel.
Returns the decimal value of the character if one is received
0 if the channel does not support text reception
-1 only on error/hangup.
Notes Specify timeout to be the maximum time to wait for input in milliseconds, or 0 for infinite.Most channels do not support the
reception of text.

TDD MODE <on|off>
Function Enable/Disable TDD transmission/reception on a channel
Returns 1 if successful
0 if channel is not TDD-capable.
Notes

SEND IMAGE <image>
Function Sends the given image on a channel
Returns 0 if image is sent, or if the channel does not support image transmission
-1 only on error/hangup.
Notes Most channels do not support the transmission of images.
Image names should not include extensions

STREAM FILE <filename> <escape digits>
Function Send the given file, allowing playback to be interrupted by the given digits, if any
Returns 0 if playback completes without a digit being pressed
the ASCII numerical value of the digit if one was pressed
-1 on error or if the channel was disconnected
Notes Use double quotes for the digits if you wish none to be permitted.
The file extension must not be included in the filename.

SAY NUMBER <number> <escape digits>
Function Say a given number, returning early if any of the given DTMF digits are received on the channel
Returns 0 if playback completes without a digit being pressed
the ASCII numerical value of the digit if one was pressed
-1 on error/hangup
Notes

GET DATA <file to be streamed> [timeout] [max digits]
Function Stream the given file, and receive DTMF data
Returns the digits received from the channel at the other end
Notes

SET CONTEXT <desired context>
Function Sets the context for continuation upon exiting the application
Returns
Notes

Netweb Confidential                                        Page 44                                      Property of Netweb Group, Inc.
                                                                                       netweb Group, Inc.
                                                                                       385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                       Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                        We are your one source for VOIP and Broadband


SET EXTENSION <new extension>
Function Changes the extension for continuation upon exiting the application
Returns
Notes

SET PRIORITY <num>
Function Changes the priority for continuation upon exiting the application
Returns
Notes

RECORD FILE <filename> <format> <escape digits> <timeout> [BEEP]
Function Record to a file until a given dtmf digit in the sequence is received
Returns -1 on hangup or error

Notes The format will specify what kind of file will be recorded.
The timeout is the maximum record time in milliseconds, or -1 for no timeout


Install Card
First you have to get that card in the box. Presumably you've installed PCI cards with Linux before, so I won't go into that. What I will
recommend is to just include one FXO interface on the card for starters. This will make my VERY simple configurations work for you.
Put it in the left most slot so it will come up as channel 1.

Configure Card
So you've rebooted and Linux has come up, and you have a root bash prompt, what now? Well you have to modprobe the hardware
to get Linux to see it. But don't go modprobe-ing just yet. You have to configure the /etc/zaptel.conf file. This file is not an Asterisk
configuration file. It is merely for the Digium hardware. When Linux loads those drivers, it looks for this configuration file. For the
configuration above you just need these three lines:

loadzone=us
defaultzone=us
fxsks=1

Ok, so go ahead and modprobe now:

$ modprobe zaptel
$ modprobe wcfxs

For this card, no matter what type of interfaces you have on it, you just need these two drivers. Did you get any errors? Depending on
the version of Linux, you may be using udev. If you are, like I was, you may get some errors about some device files that are missing:

$ modprobe wcfxs
Notice: Configuration file is /etc/zaptel.conf
line 4: Unable to open master device '/dev/zap/ctl'

You're in luck. The solution is trivial. Well it wasn't for me, but I had no clue! Take a look at the Asterisk source tree, and you'll find a
file README.udev. This file has some lines which you'll add to the appropriate file in /etc/udev/rules.d and then you're done. Retry the
modprobe (you may have to rmmod first) and be sure there are no errors. Verify that there are devices in /dev/zap, and you can move
on!

Configure Asterisk
Up to this point you were just configuring the hardware. Now you'll look at Asterisk configuration. Believe it or not, you really only need
Netweb Confidential                                        Page 45                                       Property of Netweb Group, Inc.
                                                                                          netweb Group, Inc.
                                                                                          385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                          Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                           We are your one source for VOIP and Broadband


to configure two files for starters. They are the zapata.conf file, and the extensions.conf file. If you add an IP phone, you'll put that
configuration in sip.conf. There are lots of files in there which can confuse a newbie, I know they confused me. When I looked at
sip.conf I thought, well Asterisk is a sip server, so perhaps some of the Asterisk configuration info is there. Nope, just sip phones go
there.

Ok, lets start with the zapata.conf. It tells asterisk about your zaptel device. Asterisk does not use the zaptel.conf for this, that file is
only for Linux, the driver, and is used during the modprobe phase. There are two types of devices that can be in your zapata.conf.
Telephone lines, and analog phones. Remember an FXO is for a analog telephone line. For now we'll just deal with that to keep
things simple.

Here's a zapata.conf that should work for your one line TDM400P card:

context=incoming
signalling=fxs_ks
echocancel=yes
echocancelwhenbridged=yes
relaxdtmf=yes
rxgain=1.5
txgain=1.5
immediate=no
busydetect=no
callprogress=no
musiconhold=default
usecallerid=yes
callerid=asreceived
channel => 1

Now you're gonna be intimidated by all this telephony gobbledigook, for sure. To tell you the truth, I don't know what every single one
of those lines is for. As I run into issues, I research each one. There are three lines that I will comment on though. The context line
has a name 'incoming'. Remember this name, as it links us to a configuration *SECTION* in the extensions.conf file. Also the
signaling line. It looks wrong, but despite the confusion, it is right for your TDM400P with one FXO interface. See other Asterisk
technical documents for details on this. Also important is the last line, channel. Remember you included one FXO device, so it's
channel one, if you had more this number would correspond to the port on that card.

And now the file which initially will boggle your mind, but eventually you will grow to love and dream about, the extensions.conf. This is
where all the exciting stuff happens. What to tell the caller the time and date, you can do that here, play an intro message, record a
gsm file, or more importantly tell asterisk which phones (SIP or analog) should behave as which extension.

This configuration file was originally based on these files, though I've made a lot of changes.

[globals]

[extensions]

; example of recording gsm file
;
exten => 12,1,Wait(2)
exten => 12,2,Record(/tmp/asterisk-recording:gsm)
exten => 12,3,Wait(2)
exten => 12,4,Playback(/tmp/asterisk-recording)
exten => 12,5,Wait(2)
exten => 12,6,Hangup

Netweb Confidential                                         Page 46                                         Property of Netweb Group, Inc.
                                                                                     netweb Group, Inc.
                                                                                     385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                     Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                      We are your one source for VOIP and Broadband


; attendant reads back date + time then hangs up
;
exten => 13,1,DateTime()
exten => 13,2,Wait(1)
exten => 13,3,DateTime()
exten => 13,4,Hangup

; attendant reads back calling phone # then hangs up
;
exten => 14,1,Wait(1)
exten => 14,2,SayDigits(${CALLERIDNUM})
exten => 14,3,Wait(1)
exten => 14,4,SayDigits(${CALLERIDNUM})
exten => 14,5,Hangup

; access the voicemail system by using extension 15
;
exten => 15,1,VoicemailMain
exten => 15,2,Hangup

exten => 23,1,Answer
exten => 23,2,Wait,1
exten => 23,3,mp3player(/usr/src/asterisk/sounds/fpm-calm-river.mp3)
exten => 23,4,Wait,20
exten => 23,5,Hangup

[incoming]

; Incoming calls from digium card (channel 1)
;
exten => s,1,Answer
exten => s,2,DigitTimeout(10)
exten => s,3,ResponseTimeout(20)
exten => s,4,Background(vm-extension)

; hangup if caller does nothing
;
exten => t,1,Hangup

; incoming calls can use extensions
;
include => extensions

There's a lot going on here, so I'll explain things at a high level. First off, this file only manages INCOMING calls right now. We have
not configured any phones to call OUT with yet. First thing, fire up asterisk, and then make a call into your PBX from another phone,
perhaps a cellphone.

For right now, you will just here the attendant say "EXTENSION?". Enter one of the extensions. Extension 12 in our configuration will
record a gsm audio file which can be used with Asterisk, as we'll explain later. With extension 13, the attendant will read back the date
and time, and with 14 they will read back the calling phone number. Extension 15 will take you to the voicemail system, which is menu
driven, and similar to other telephone based voicemail systems you've used, perhaps with your cellphone provider. Lastly we've
included extension 23 as a sample of how to play an mp3 music file.

Configure a SIP Phone
Netweb Confidential                                      Page 47                                       Property of Netweb Group, Inc.
                                                                                      netweb Group, Inc.
                                                                                      385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                      Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                       We are your one source for VOIP and Broadband


Now that you have seen how incoming calls work, we'll configure a phone to work with Asterisk. I prefer to use an SIP phone here, as
it doesn't complicate the zaptel configuration. If you want to add an analog phone, you'll first add the FXS module to your TDM400P,
then add a line for that in the zaptel.conf, do the modprobes as before, and then add some lines in your zapata.conf. There are plenty
of documents to describe this, refer to VOIP-Info for more information.

Ok, SIP phones. I used the Grandstream Budgetone 101 which can be had for as little as $65. To get this phone to work (after you
plug it into your local network) you'll be doing three things. You will need to let Asterisk to know about the phone by editing the
sip.conf file, configure the phone itself through it's web interface, and lastly you will need to configure the extensions.conf file to use
the phone to make outgoing calls.

Ok, so fire up your editor, and edit your sip.conf file:

[general]
port=5060
bindaddr=0.0.0.0
tos=lowdelay
disallow=all
allow=ulaw
context=INVALID

[21]
type=friend
#host=192.168.0.15
host=dynamic
musiconhold=default
context=local-access
canreinvite=no
qualify=300
callerid="Budgetone                          101                         SIP                               Phone"                        <21>
mailbox=21
nat=yes

The important things here are the [21] which indicates the login for the phone (see IP Phone config below), and also the context line.
The string 'local-access' indicates where configurations for this phone go in extensions.conf. This works similar to how the context of
'incoming' in the zapata.conf file takes you to the 'incoming' section of the extensions.conf file. The host line of 'dynamic' means use
DHCP. I had some confusing results with this line, so check the wiki or the asterisk-users email list for the official word. I found a wiki
page specific to the Budgetone 101.

Ok next up, you want to bring up the web-based configuration for the Budgetone 101. You can find out the IP address that the phone
was given (configured for DHCP by default) by just using the MENU button on the phone itself. Use the arrows to get to that item, and
note the IP address. Then point your browser there. The default password is 'admin'. The only fields I changed (well besides changing
the default password!!) is the SIP Server, which is the IP address of your Asterisk box, the SIP User ID which I set to '21' and the
Authenticate ID which I also set to '21'. Then click 'update' at the bottom, go back to the begining again, login again, and then click
'reboot'. The phone light should blink on, and you should be good to go.

Last up is the extensions.conf file. You need to add a section for outbound calling using the SIP phone, and inbound calls *TO* your
sip phone. Remember all the extensions we created before were sort of virtual, merely performing some function, and then hanging
up.

Here's what I have for incoming calls to the SIP phone:

exten => 21,1,Dial(SIP/21,20)
exten => 21,2,Voicemail(u${EXTEN})
Netweb Confidential                                        Page 48                                      Property of Netweb Group, Inc.
                                                                                    netweb Group, Inc.
                                                                                    385 Main St. Suite # 4A, Metuchen, NJ 08840
                                                                                    Ph: 732-213-2422: email: info@netwebgroup.com
                                                                                     We are your one source for VOIP and Broadband


exten => 21,3,Hangup
exten => 21,102,Voicemail(b${EXTEN})
exten => 21,103,Hangup

Add these lines in with the other extensions, perhaps before 23, be sure it goes ABOVE the [incoming] line. And lastly, at the
end of the file add these lines:

[local-trunks]
exten => _9NXXXXXX,1,Dial(Zap/1/${EXTEN:1})
exten => _9NXXXXXX,2,Congestion

exten => _9NXXNXXXXXX,1,Dial(Zap/1/${EXTEN:1})
exten => _9NXXNXXXXXX,2,Congestion

[local-access]
ignorepat => 9 ; Continue dialtone after 9 on zap devices
include => extensions
include => local-trunks ; Access to Local numbers

Ok, now restart asterisk (restart now from the CLI), or to be absolutely sure, use the kill command, and start it again. Pickup your
Budgetone 101 handset, you should hear dialtone, and the little ethernet rj45 jack symbol should be visible in the upper left corner.
Try dialing the same extensions you dialed before. Now you're internal (you're not on your cellphone, dialing into the asterisk box from
a POTS line). Now dial 21, you should get voicemail with the busy message. Now use your cellphone, and dial into your asterisk box
again. When asked for extension, enter 21. Do you hear your Budgetone phone ringing? Let it ring and ring, voicemail should pickup,
but this time you get the unavailable message! Congratulations, you're grooving with Asterisk!

One more thing I did was create a new intro message. Use extension 12 to record a GSM message "Welcome to Heavyweight
Internet Group, use extension 10 for Susan, 11 for Jimbob, and 12 for Nadia". Now you'll find a file /tmp/asterisk-recording.gsm,
rename it to iheavy-welcome.gsm, and copy it to /var/lib/asterisk/sounds. Lastly edit your extensions.conf file one more time, and
change this line:

exten => s,4,Background(vm-extension)

to this line

exten => s,4,Background(iheavy-welcome)

Back to the asterisk command line enter extensions reload. Call into your asterisk box to hear your brand new welcome message!

Conclusion:

There are millions of other cool and exciting things you can do with Asterisk such as having different welcome messages for different
times of day, company directory, music on hold, and so on. I recommend reading through the wiki to find more specific information for
your setup. Perhaps you can get Asterisk to talk directly to a VOIP provider that supports IAX (Inter-Asterisk eXchange) protocol
instead of SIP. Find out more on this voip providers page. You may want to consider getting a switch if you're going to be handling a
lot of calls.

For more interesting discussions on VOIP, I recommend Om Malik on Broadband and the VOIP weblog as two places to find
interesting VOIP discussion. And lastly the most important resource related to Asterisk is the insightful and volumous asterisk-users
email discussion list. A good dose before breakfast makes for a fine day!

Questions about this document, email me at: seshukanuri@netwebgroup.com
Netweb Confidential                                      Page 49                                      Property of Netweb Group, Inc.
                                netweb Group, Inc.
                                385 Main St. Suite # 4A, Metuchen, NJ 08840
                                Ph: 732-213-2422: email: info@netwebgroup.com
                                 We are your one source for VOIP and Broadband




Netweb Confidential   Page 50                     Property of Netweb Group, Inc.

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:187
posted:9/17/2011
language:English
pages:50