Thursday, November 24, 2011

A simple IVR and Queue example where customer listens to marketing materials and also can leave voice message by '*'

A customer asks for an automated greeting system where callers listen to marketing messages before being picked up by agents.  They can also press '*' anytime to quit waiting in the queue and leave voice message.

1.    In the dial plan, we use the option 'Hn' in the Queue command.  The 'H' allows caller to hangup a ringing call by whatever defined as the disconnect sequence in features.conf.  Note that we also need 'n' such that the retry cycle is skipped and the Queue command exits.


exten => 12345,1,noop
; answer before playing the sound files
exten => 12345,n,answer
exten => 12345,n,wait(1)
exten => 12345,n,Set(TIMEOUT(digit)=2)
exten => 12345,n,Set(TIMEOUT(response)=10)
exten => 12345,n,Background(custom-ivr/custom-welcome)
;exten => 12345,n,Set(TIMEOUT(digit)=5)
; use H to let caller hangup a ringing call to agent by disconnect key seq in features.conf
; use n such that caller skips the retry cycle and exits the queue command
; otherwise, caller still stays in the queue redialing to agent
exten => 12345,n,Queue(custom-queue,Hn,,,300)
; customer leaves voice message by keying '*' or upon wait timeout of 300s
exten => 12345,n,VoiceMail(custom-vm@custom-ivr)

; we still need this extension to handle '*' pressed during the welcome greeting
exten => *,1,noop(i quit waiting)
exten => *,n,VoiceMail(custom-vm@custom-ivr)

To verify the current disconnect sequence, we can use 'feature show' in the CLI.

2.    The marketing messages are specified as a MOH class 'custom-ivr' in the queue definition.  


strategy = ringall
musicclass = custom-ivr
ringinuse = no
wrapuptime = 30
joinempty = yes

3.    Then we can put the marketing messages in a directory /var/lib/asterisk/moh/custom-ivr.  These sound files are preferably formatted to minimize transcoding. 



We can use 'core show translation' in CLI to show how costly Asterisk performs the transcoding.

4.    Alternatively, the queue 'context=' also allows caller to quit by keying a defined extension.  For example, with below configurations, caller can also quit the queue by '*'.


context = custom-ivr


; no need for Hn
exten => 12345,n,Queue(custom-queue,,,,300)

exten => *,1,noop(i quit waiting)

Wednesday, October 19, 2011

Blind Transfer and Ring back in Elastix

The followings apply to Elastix 2.0.0-36 &  Asterisk on CentOS release 5.5.

In Elastix, we can perform blind transfer and ring back us if the transferee does not answer.  Note that here assumes you are transferring call using Asterisk feature, not the IP phone's own transfer function.  

Firstly, we have to setup a TRANSFER_CONTEXT.  Dialplan execution will jump to here on transfer.

TRANSFER_CONTEXT = blindxfer_ringback

Next, we make use of the BLINDTRANSFER variable to ring back in the context [blindxfer_ringback]

; the destination ext should not have vm enabled
exten => _X.,1,NOOP(${BLINDTRANSFER})
exten => _X.,n,set(timeoutd=15) ; set timeout in seconds to dial the transferee
exten => _X.,n,set(extLeng=${LEN(${EXTEN})})
exten => _x.,n,dial(local/${EXTEN}@from-internal,${timeoutd})
exten => _X.,n,Gotoif($["${DIALSTATUS}" = "ANSWER"]?hangup:callback)
; strip the 'SIP/' and ring back
exten => _X.,n(callback),dial(local/${BLINDTRANSFER:4:${extLeng}}@from-internal,,tr)
exten => _X.,n(hangup),hangup()

How does it work
  1. During a conversation, when you want to transfer caller, you press '##' followed by the transferee extension and '#'.
  2. You can hangup your phone.
  3. The caller now hears music while being connected to the transferee.
  4. If the transferee does not answer, Asterisk will ring back you.
Asterisk feature
The '##' is the key sequence to initiate blind transfer in Asterisk.  You can verify the actual sequence defined in your Elastix.

  1. PBX>PBX Configuration>Feature Codes
  2. Or you can check it in CLI.
*CLI> features show
Builtin Feature           Default Current
---------------           ------- -------
Pickup                    *8      *8
Blind Transfer            #       ##

Friday, October 07, 2011

Tips of using Elastix in Business Center/Virtual Office

Business center usually gives its client a business contact number to receive inbound calls.  Caller is greeted properly using the client's name and then forwarded to the client who is probably located remotely.
It is desirable that the agent can identify which client is being called before picking up the phone.
Here describes the steps taken to accomplish it using Elastix.
The scenario applies to Elastix 2.0.0-36 and most common IP Phones with LCD display.  The business center subscribes a T1 trunk (bundled with 200 local numbers) from a local telephone provider.  The local numbers are allocated to its clients.
1.    Create a queue of agents
PBX > PBX Configuration > Inbound Call Control > Queues
You can simply enter the agent extensions in the 'Static Agents' field.
2.    Add inbound route
PBX > PBX Configuration > Inbound Call Control > Inbound Routes
Input the 'DID Number' and the corresponding company name in the 'CID name prefix' field.  The DID number is the business contact number that is given to the client.


Direct incoming call to the call queue created above.

Create inbound route for each DID number you assigned to clients.
What would the agent see?
When a call comes in, the agent can see the corresponding company name on the phone LCD display.  Note that the display length varies with phone models. 

Wednesday, September 28, 2011

Start Asterisk as service

After going through the Asterisk installation steps, we usually want to start it as a service.
Usual steps of Asterisk Installation
./configure   -- check if our system is suitable for Asterisk installation
make menuselect  -- it is an optional step, allowing you to select additional module, eg, mysql_cdr
make – the compilation process
make install – setup the paths, copy files to asterisk directory, etc.
make samples – an optional step to put a set of sample config in your installation (it will over-write existing config)
make progdocs – also an optional step to setup the documentation
At this stage, you should be able to run Asterisk as 'asterisk –cvvvvvv' in foreground.  But it is more desirable to setup a service and it can be achieved easily by:
Setup Asterisk Service
make config
There is a set of platform-specific templates in <asterisk-src-dir>/contrib/init.d, designed to be used for service startup script.  The 'make config' will base on one of these templates to create the Asterisk startup script in /etc/init.d.  To verify the result:
#chkconfig –list asterisk
#asterisk        0:off   1:off   2:on    3:on    4:on    5:on    6:off
Then, you can start asterisk by 'service asterisk start'.

Monday, September 26, 2011

Group Pickup in Elastix

The following steps apply to Elastix 2.0.0-36 on CentOS 5.5.
1.    edit /etc/asterisk/features_featuremap_custom.conf by adding "pickupexten = *8"
2.    restart Elastix by 'amportal restart'
3.    in PBX > Extensions > field 'callgroup', assign each extension to a call group (each extension can belong to only one group;  group range is 0-63)
4.    in PBX > Extensions > field 'pickupgroup', specify the call groups an extension is authorized to pick-up (you can enter a range and/or discrete group number, e.g., 1-3,5,9,etc)
5.    when you want to pick up a ringing call, off hook and then *8.
6.    however, if there is more than one ringing call, it is up to Asterisk to deliver which one to you.
You can verify the pickup key in asterisk as below.
*CLI> features show
Builtin Feature           Default Current
---------------           ------- -------
Pickup                    *8      *8

Wednesday, September 14, 2011

IP PBX vs Legacy PBX

A customer asked for the differences between IP PBX and legacy PBX.
IP PBX is usually a powerful linux/unix server with an Asterisk-based PBX software.  Examples are Elastix and Trixbox.  A PRI T1/E1 or FXO card is required to connect the telco side.
Vendors such as Digium, Snom and Grandstream also manufacture all-in-one appliances that simplifies the installation and configuration. 
Features and flexibility
Being a software, IP PBX  is more feature-rich and customizable than a traditional PBX.   For instance, we can customize IVR, call queues, ring groups, followme, voice recording and many other features in the IP PBX.
The IP PBX also provides a web-based utility for IT staff to conveniently perform daily tasks.  
Transmit audio over internet to save money
Voice is transmitted over a packet network (Internet, LAN) rather than phone lines.  Though it sounds trivial, it has important implications:  it can help to save money. 
The main office can communicate with remote branch offices over internet and enjoy free calling among the extensions.  No IDD charge is incurred. 
Note that we need to use IP phones with IP PBX.   These phones are connected to your company LAN, rather than telephone lines.  There are many brands of IP phones and they are inter-changeable.  There is basically no vendor lock-in.
The IP nature also enables remote extensions whereas we can have extensions outside office, such as home, trip or even our mobiles* as long as internet access is available.  It is an extra convenience that legacy PBX cannot offer. 
*a sip client app is required
Voice quality
You will find voice quality the same.   The company LAN is a 10/100M ethernet, which is a pretty sufficient bandwidth for voip conversation.  A typical two-way call merely consumes around 150kbps.
Nevertheless, IT administrator should pay more attention to conditions that could saturate the LAN, e.g packets sent from infected PC or lengthy download/upload.
Separating voice and data into two subnets is suggested.
Ongoing support
In the long run, customer will see savings in maintenance costs as the IP PBX configuration is self-serviced. 
When your business grow, you need to add more extensions.   It can be accomplished easily in IP PBX without adding ports as legacy PBX requires.  You will find IP PBX more scalable.
Buying considerations : Replacement or parallel run
Customer is generally more interested in IP PBX when starting a new office or the legacy PBX is almost fully depreciated.  Some customers also chooses to install the IP PBX in front of the legacy PBX such that they can start using the new features while keeping the old investment.  In this scenario, the IP PBX has a 2-port T1 card, one port connecting to telco and the other connecting to the legacy PBX via a cross cable.

Saturday, September 03, 2011

How to read mbox file in Thunderbird

In linux/unix based email systems, we usually archive mails in mbox format.  Although it is a common format, our Microsoft email clients such as Outlook just does not read mbox straightforwardly.
Now, we can use Thunderbird to recover emails out of the archives easily. The below steps apply to version 6.0.1.
1.    Download Thunderbird from
2.    After installation, we have to setup an email account.  This is just like how we configure an account in Outlook.
3.    Next, we need to find out the folder location in Thunderbird.
Edit>Folder Properties
4.    Close Thunderbird and place our mbox archive in the folder.
5.    Restart Thunderbird and you should see the contents.

Thursday, August 25, 2011

Housekeep Asterisk Log Files

Asterisk log files can grow very large unawared, eventually leading to disk space problems. 
We can take a few measures to maintain log history and housekeep old ones automatically.
1.    Review the /etc/asterisk/logger.conf
This file specifies the logging level of asterisk.  In a production system, it is sufficient to turn on message log only while keeping the others disabled. 
;debug => debug
console => notice,warning,error,debug
messages => notice,warning,error
;full => notice,warning,error,debug,verbose
The modified logging level is made effective by:
asterisk –rx 'logger reload'
2.    Use logrotate to rotate and remove historical files
This utility is helpful in housekeeping outdated log files.  The logrotate is usually invoked from /etc/cron.daily and it looks for how and what to process in the /etc/logrotate.conf.
As illustrated in the logrotate.conf below, we rotate log files on weekly basis and keep 4 weeks.  Rotated log would have a timestamp as suffix.  Older files would be deleted automatically.  Note that we can compress rotated files to further reduce disk usage.  Individual rotation information are put in /etc/logrotate.d.
# see "man logrotate" for details
# rotate log files weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
# use date as a suffix of the rotated file
# uncomment this if you want your log files compressed
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
In /etc/logrotate.d/, we can create a file (eg, named as 'asterisk') to specify which asterisk log files we want to housekeep.  We need to run 'logger reload'.  Otherwise, Asterisk still writes to the old file.
/var/log/asterisk/messages  {
    /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null

Thursday, August 18, 2011

Asterisk Native Bridge vs SIP External Native Bridge

The difference can be illustrated by below scenario:
  1. Dial creates an outbound PBX channel and asks one of the channel drivers to create a call
  2. When the call is answered, Asterisk bridges the media streams so the caller on the first channel can speak with the callee on the second, outbound channel
  3. In some cases where we have the same technology on both channels and compatible codecs, a native bridge is used. In a native bridge, the channel driver handles forwarding of incoming audio to the outbound stream internally, without sending audio frames through the PBX.
  4. In SIP, theres an "external native bridge" where Asterisk redirects the endpoint, so audio flows directly between the caller's phone and the callee's phone. Signalling stays in Asterisk in order to be able to provide a proper CDR record for the call.

The above information is taken from

Friday, July 29, 2011

Add Google +1 button to PhpBB

The Google +1 button is analogous to the Facebook Like.  With a few steps, we could add this feature to our PhpBB-based forum.
In the first place, edit two files : overall_header.html and viewtopic_body.html in the template folder as below.
1.    find </head>
2.    in front of it, insert <script type="text/javascript" src=""></script>
1.    find <div class="postbody">
2.    inline add to the appropriate position to show the +1 button
<g:plusone size="medium"></g:plusone>
It is advisable to refresh to template if the +1 button does not appear.
1.    Open PhpBB Administration Control Panel
2.    Click the 'STYLES' tab
3.    Click 'Templates' and 'Refresh'

Thursday, July 21, 2011

Asterisk dialer with Outlook 2010

It would be convenient if we just merely point and click a contact in our Outlook address book and our Asterisk PBX would make the call.  This article outlines the steps taken to enable an Asterisk dialer in Outlook 2010.
These steps are tested under below environment.
Microsoft Outlook 2010
Windows 7 (32-bit)
Elastix 2.0.0-36
The office extensions are managed by Elastix/Asterisk.  They are configured as sip peers and physically vary from IP Phones, analogue phones via ATA and Xlite softphones. 
In essence, we need a windows TAPI driver that can talk with Asterisk via Asterisk Manager Interface(AMI).  When we click to dial an Outlook contact, the TAPI driver sends an Originate command to our Asterisk PBX which performs the dialing.  It dials to our phone extension first and then to the contact, bridging both parties in a conversation.

TAPI Driver

An open source TAPI drvier is selected.  It is available from  The version we tested is v.1.6.4



1.    In the first place, we need to enable AMI and define an AMI account in the Asterisk box.

AMI is configured in /etc/asterisk/manager.conf.

;The general section below enables Asterisk to listen for AMI connection in port 5038.






;It defines an AMI account – astdialer – to be used by the TAPI driver

;It is advisable to only permit connections from internal ip, as accomplished by the 'deny and permit'



read = system,call,log,verbose,command,agent,user,originate

write = system,call,log,verbose,command,agent,user,originate

deny =

permit =


To make the changes effective, we can reload manager module by:

asterisk –rx 'manager reload'


2.    Next, we install the TAPI driver in our PC.

The installation process will present a screen to capture a) our phone extension and b) AMI connection parameters.

Line DN    :    It refers to our phone extension;  it becomes the 1st leg SIP/<Line DN> in the Originate command

Line Prefix    :    What input here would be stripped when sending to Asterisk as the dial string.

Context    :    It refers to the dialplan context in Asterisk for incoming and outgoing calls

Host IP    :    It refers to the ip/dns of our Asterisk PBX

Port    :    refer to the AMI above

User    :    refer to the AMI above; in our example, we should input 'astdialer'

Password    :refer to the AMI above


3.    We also need to add a key in Windows 7 registry for TAPI support (ref to )


The registry subkey required is:

KEY_LOCAL_MACHINE\Software\Microsoft\Office\Outlook\Call Integration

with a DWORD value:



With the above done, we should see a 'call' icon on right clicking an Outlook contact.



Asterisk will firstly ring our extension and, upon connected, dial the other number.  The callee would have seen incoming call from us (or what configured as the proper caller id to present) as if we manually dialed the number.




Wednesday, July 13, 2011

Why we receive spam not attending to us?

Recently, a client asks why she receive emails not attending to her. 
The internet email system is responsible for delivery.  It functions like our post office.  As long as we write a correct postal address, our post office can deliver a letter to the address.  The letter contents (who wrote the letter and who should receive the letter) is not under strict control.
Similarly, the internet email delivery mechanism (which is a number of computers running smtp services) only deals with routing and delivery of email messages.  The 'from: to:', etc. are part of the contents and therefore not under control by the smtp delivery.  Spammers can alter or fake these fields so as to broadcast purposely and hide their real identity. It explains why we receive so many spams, some with forged sender and some are not even attending to us.
It is our system administrator (who is in charge of our company email server) to take care of spam filtering.  Common measures are checking the sending ip against DNSBL (eg spamcot, spamhaus) and deploying some kind of anti-spam appliance.  The administrator also needs to ensure his email server is NOT acting as open relay which could otherwise make the server itself a spam source.  It is also advisable to disable smtp connection from internal LAN PC to outside because the smtp connection is usually initiated by the company email server only.  If there is some other PC making the connection, then it is likely from an infected one.

Thursday, July 07, 2011

Make VOIP call from Android phones

The following applies to Android 2.2 on Motorola Milestone 2.
We can dial out and receive VOIP calls from our smartphone (eg Nokia, Android, etc.).  The primary benefit is saving IDD and roaming charges when we travel abroad. 

The prerequisite is that we have subscribed an VOIP account from a Internet Telephony Service Provider (ITSP) and ideally have public internet access for free (eg, wifi in coffee shops).  To make an IDD call (eg to our home town) at low cost, we dial over the internet to the ITSP that eventually routes our call to the destination, bypassing part of the telephone network and thus saving call charges.
The ITSP is usually a telecom sevice provider that operates a VOIP gateway to serve calls from the internet side and routes to the telephone switch network.  They usually charge account maintenance fee monthly and termination fee per call basis.  Local termination is usually free while overseas termination are almost charged the same as if calls were originated locally.
The term VOIP (voice over IP) describes the mechanism and protocol we send voice over the internet.  It centers around SIP (session initiation protocol) which is now the industry protocol standard of transmitting voice over packet switched network.  Our smartphone has to become a sip compliant device in order to make VOIP calls.  It is surprisingly easy as installing an SIP client apps would suffice.
There are a number of SIP client apps on Android.  I installed Sipdroid ( ) on my MS2 because it is free and simple to use.  I take a VOIP account from ZONETEL ( (one of the HK based ITSP) as illustration.
In the first place, I configure the VOIP account in Sipdroid.  The VOIP account just consists of three information: 1) the ITSP server address, 2) account username, 3) account password
To make a call, we type the destination number and enter to proceed.
This VOIP account is bundled with a HK local telephone number for receiving call.  It means we can be reached via this number even when we are abroad and the Sipdroid apps is running.  In other words, it helps to save roaming charge.

Fight spam with MailScanner

One of our clients is using MailScanner ( ) as anti-spam filter on a fedora system.  The ms provides many options to fine tune how to handle spam emails.
In the first place, we have to enable the spam check feature in /etc/mail/MailScanner.conf and tells ms which spam filter to use.
# Spam Detection and Spam Lists (DNS blocklists)
# ----------------------------------------------
Spam Checks = yes
Spam List = spamhaus-ZEN
The information we provided to the directive 'Spam List' is a reference to the spam filter definitions in spam.lists.conf.
The default installation of spam.lists.conf already includes some common spam filter definitions and we can add further as necessary.
Next, we need to define how to handle spam emails in /etc/MailScanner/MailScanner.conf:
Spam Actions = store forward
The above instructs ms to store a copy of the incoming spam in quarantine and also forward to  Alternatively, we can simple discard them as below:
Spam Actions = delete
To make the changes effective, we have to restart ms.  Mailscanner will also restart itself regularly (see the 'Restart Every =' in mailscanner.conf).

Wednesday, July 06, 2011

Difference between 800 and 400 toll-free numbers in China

800 toll-free numbers

800 toll-free numbers are commonly called "800 免费电话", the official name is "被叫集中付费业务" (called party collect paid service), which means the cost of the call is borne not by the caller but by the party receiving the call.
800 toll-free numbers in China are ten-digit numbers beginning with "800". Three is no prefix before "800". (In US, "1" must be used before "800" when dialing from a landline).
800 toll-free numbers are not accessible to some mobile network subscribers.

400 toll-free numbers
400 service is called "主被叫分摊付费业务" (calling party and called party split-paid service), which means the calling party pays for the local access fee and the called party pays the toll (long distance) fee.
400 toll-free numbers in China are ten-digit numbers beginning with "400".
400 toll-free numbers can be accessed by all fixed-line and mobile phones.
Callers have to bear local access charges from their service providers.

Wednesday, June 15, 2011

Archive both incoming and outgoing emails in Sendmail/MailScanner

With MailScanner, we can archive incoming or outgoing or both easily.
Firstly, we indicate a ruleset file in the 'Archive and Monitoring' section of MailScanner.conf.
# Mail Archiving and Monitoring
# -----------------------------
Archive Mail = %rules-dir%/archive.rules
In the ruleset file, we specify a location to where emails are archived.  We can use 'From:/FromOrTo:/To:' to tell MS the scope of emails to archive.  In this example, all incoming and outgoing emails are archived to one single mbox file on daily basis.
FromOrTo:       *       /path_of_the_storage_location/_DATE_.mbox
The mbox format is accessible by many email clients.  Please see

Friday, June 03, 2011

Send fax over internet

There are a couple of reasons to send long-distance fax over internet.  Cost saving should be the primary one.  As fax data is transmitted over public internet, we do not need to pay IDD charge to telephone company.  In other cases, we just want to bypass the premise-provided telephone network, for instance, when we need to fax out from hotels or business centers. 
Apart from outbound fax, it can work in the reverse path; you can receive fax over internet.  Some internet fax service providers offer national fax numbers and forward incoming faxes over internet to you.  In other words, it gives your sender the impression of faxing to a local number.  Isn't it a beautiful feature?    
Nevertheless, you still have to pay some recurring charges such as subscription and rental fees to the internet fax service provider.
How to put things together:
A typical scenario of sending and receiving fax over internet is shown above.  The fax machine on the left is the one you use for internet faxing.  It connects to a small networked device (we call it ATA) instead of a telephone socket on the wall.  The fax machine on the right is just an ordinary one.  The diagram basically involves four elements.
ITSP – Internet telephony service provider
This is the company that routes fax calls over internet to and from your fax machine.  You need to obtain a service account (we call it a SIP account) from them and configure it in a small device (ATA) to work with your fax machine.  The ITSP usually provides you a fax number for receiving fax.  Some examples of such ITSP are,,
Telephone network – the part A above
It refers to the public switched telephone network (PSTN) that we use from day to day.  Our mobiles, landlines and fax machines are communicated within the PSTN.  The ITSP is usually a gateway (or it lines up another in behind) to PSTN and therefore could terminate your fax to and receive from an ordinary fax machine (the one on the right). 
Internet – the part B above
ATA – analogue terminal adatpor
It is provided by the ITSP and its purpose is connect your fax machine to them.  It is a small device that provides two ports, one for connecting your fax machine and one for internet connection.  Usually, the ATA device is pre-configured with a SIP account. The SIP account identifies you as a customer to them. 
Now, you operate your fax machine as usual and the internet part is handled by the ITSP.
We all heard or used Skype or similar products that transmit voice over internet to save phone bills.  We might not aware that the internet is not a stable and controllable environment in respect of bandwidth and latency.  Nowadays, voice over internet could be optimized by various techniques such as lossy codecs and jitter buffer to control the demand of bandwidth and handle network delay.  These are practical solutions because we are talking about voice  -- in fact, our ears still perceive good quality even there is data loss technically.  However, fax is different.  Fax machines need much better accuracy in order to handshake, to negotiate speed and to successfully transmit.  To tackle problems of fax over IP, a protocol named T.38 is developed by ITU.  The virtue of this protocol is it encapsulates the original T.30 fax protocol in IP packets.  Both sending and receiving fax machines are then thinking they are talking to a genuine fax.  T.38 is supported by many ITSP and ATA.  It is by now the industry standard of FOIP.
Yet the world is no perfect.  Even with T.38 enabled, we sometimes see failed transmission when internet bandwidth is unstable.  In addition, high speed transmission (such as the V.34 33.6kpbs) is not well supported in practice.

Monday, May 16, 2011

Answer monitoring when the PSTN side does not support reverse polarity

In many circumstances, we need to know whether a pstn call is answered or not after dial out, for example, to start billing.
It would be a simple case when both pstn side and our fxo gateway support reverse polarity such that we could literally obtain a correct asterisk variable ${DIALSTATUS}.  As illustrated below,
exten => _X,n,dial(sip/gw/${EXTEN},g)
exten => _X.n,noop(${DIALSTATUS}
After the call is finished (use of the 'g' option), in the next priority in the dial plan, we check the ${DIALSTATUS} for ANSWER,BUSY,NOANSWER,CONGESTION, etc.
However, we sometimes see cases where DIALSTATUS is always ANSWER because reverse polarity is not supported in either parties and the fxo gateway just returns 200 OK at every callout regardless whether call is actually answered.
To circumvent this situation, we could use BackgroundDetect as an approximate answer detection mechanism.  It is approximate because call answer is not determined by circuit signal, but by detecting human answer pattern.
For instance, If we initiate outbound calls via call file, we could bridge the always answered call to BackgroundDetect.
Channel: SIP/gw/XXXXXXXX
Context: outbound
Extension: answer_monitor
exten => answer_monitor,n,BackgroundDetect(silence/10,1000,50,4000)
exten => answer_monitor,n,noop('machine')
exten => talk,1,noop('human')
In our scenario, the application BackgroundDetect plays a silence of 10s during which noise is monitored in the receiving direction.  If it detects any noise period of length between 50ms and 4000ms, followed by a silence of 1000ms, it jumps to the talk extension.  The figures above are assumed to reflect typical human 'hello'.

Wednesday, April 27, 2011

How to setup Elastix SIP trunk with ZONETEL's DID service.

There are increasing number of Elastix customers connecting to ZONE's DID service.  Here below highlights the major steps.


First, we need to define the SIP trunk for inbound/outbound calls.


1.    Basic>Trunks>Add Trunk

General Settings


Outbound callerid = 5804xxxx


Outgoing Settings


Peer details at least contains below:





We also need to define the register information for incoming call.


Incoming Settings


Register string has to contains:

5804xxxx:your sip


Then we need to define a route to use the outbound SIP trunk.

2.    Basic>Outbound Routes>Add Routes

;; if you dial 9 to call out via sip, etc.

Dial Patterns=


Trunk Sequence=<the trunk created in 1>


And a route for incoming call.

3.Inbound Call Control>Inbound Routes>Add Incoming Route

DID number=5804xxxx

Extensions=<the extension to answer inbound call from 5804xxxx>


Monday, April 18, 2011

Local Channel

Asterisk provides an easy way to turn any extension into a device such that we can Dial to and therefore can make use of the dial plan processing.
One example use is with call file.  We can create callfiles to telebroadcast a range of numbers with some processing (eg least cost routing).
Applcation:    Playback
in our context [lcr],  we can choose different sip/dahdi routes depending on the destination.
exten => _852XXXXXXXX, 1, Dial(SIP/${EXTEN},S(10))
exten => _853XXXXXXXX, 1, Dial(DAHDI/g1/${EXTEN},S(10))
Under many circumstances, we include '/n' in the local channel.  This switch instructs the local channel NOT to optimize out from the call path, otherwise, the channel variables and parameters used in the destination Dial() would not be available.  As in the case above, if '/n' is not used, the 'S(10)' is not effective.

Wednesday, March 30, 2011

MailScanner Mail Archiving

System administrators usually face requests from user departments to retrieve backups of incoming or even outgoing emails.  The MailScanner provides some powerful options to archive both incoming and outgoing emails to email, directory or mbox files.
To turn on mail archiving, we use the 'Archive Mail' option.  It accepts a archive destination or a ruleset file as value.  For example:
Archive Mail = %rules-dir%/archive.rules
Ruleset allows more control on which and how emails are archived.  In the ruleset below.
FromOrTo:    /var/spool/mailarchive/_DATE_.mbox
* Emails sent to will be bcc to
* Emails originated from or sending to will be archived as one mbox file per day in /var/spool/mailarchive.  The _DATE_ token will be replaced with current day in yyyymmdd format.  There are other tokens available: _HOUR_, _TOUSER_, _TODOMAIN_, _FROMUSER_, _FROMDOMAIN_.
* Note that mbox file is created when 'Missing Mail Archive Is = file' is specified in the MailScanner.conf.  Otherwise, ms assumes that the location is a directory and archives emails as queue files under it.
To make changes effective, we need to restart MailScanner. 
service sendmail stop
service MailScanner stop
service MailScanner start
We stop sendmail manually to ensure that it is brought up by MailScanner so that ms can intercepts and filters emails before the smtp daemon.

Monday, March 21, 2011

Guideline to setup SIP trunk with ZONETEL

It is quite often to have customers inquiring the sip trunk configuration issues with ZONETEL.  Here is some useful information for reference.  Usually the tricky part is with NAT and firewall ports, which leads to one-way audio or no audio at all.

Sample sip.conf (it applies to asterisk 1.4.x)





Username=<provided by zonetel>

Fromuser=<provided by zonetel>

Secret=<provided by zonetel>

Host=<the sip register server provided>










Ports required

Of course, your firewall needs to allow 5060 tcp/udp for sip signaling

And have to make sure that UDP ports are also allowed to the zonetel subnet 


Wednesday, January 26, 2011

AgentLogin vs AgentCallbackLogin

Asterisk call queue provides the mechansim to deliver incoming calls to a group of agents.  Before agent can receive calls, he/she must login the queue.  There are two types of agent login commands: AgentLogin() and AgentCallbackLogin()
Here below shows the differences between these two commands.
Allows agent to tell Asterisk where he is located (ie the extension).  He will be called back by the Queue() application later and there is no need to keep the phone off-hook.
Agent phone is permanently off-hook.  Agent just waits to be called and does not need key press to answer calls.
How agent login
Call AgentCallbackLogin().  Asterisk will ask for agent id, password and extension if these are not provided.  Agent phone is then hangup, waiting to be called back.
Call AgentLogin() and note that agent phone is then off-hook until agent logoff.
How agent receive calls
Agent phone will ring upon incoming call.  
Agent phone is permanently off-hook (online).  When call comes in, agent will hear 'beep' sound and is then connected to the customer.  Agent can press * to dump the call.  One advantage of using AgentLogin() is that agent does not need to operate the handset to answer/hangup calls.
How agent logout
Needs to call again the AgentCallbackLogin().  Asterisk will prompt to logout.
When agent hangups, he is logged out automatically
Customer callerid is not shown when using AgentLogin().  It is available only with AgentCallbackLogin().

Wednesday, January 19, 2011

Agent log off sometimes does not work

Some of our clients are using asterisk 1.4.x and occasionally find that agent logoff could not successfully log off an agent.
asterisk –rvvv
cli> agent logoff agent/xxxx
even the logoff command is executed, calls are still delivered to the agent.
in this situation, we could take a step further to unset the asterisk variable of agent/extension binding.
asterisk –rvvv
CLI>core show globals
then we look for global variables : AGENTBYCALLERID_<ext> = agentid
and clear the corresponding variable as below:
CLI>core set global AGENTBYCALLERID_<ext> ""
We've implemented the above logic in an ivr option for a few call center administrators to force logout agent.