With everything set at the Linux level, we now only need to
configure Asterisk to make use of the channels we just enabled at the
Linux level and to customize the way that Asterisk interprets and
generates information that comes in from, or goes out over, these
channels. This work is done in
/etc/asterisk/chan_dahdi.conf
.
In this file we will not only tell Asterisk what sort of channels we have (these settings will fit with what we already did in DAHDI), but also configure a number of things that will ensure Asterisk is well suited to its new home.
A key component of this change is caller ID. While caller ID delivery methods are pretty much standard within the BRI and PRI world, they vary widely in the analog world; thus, if you plugged an American analog phone into the UK telephone network, it would actually work as a phone, but caller ID information would not be displayed. This is because that information is transmitted in different ways in different places around the world, and an American phone would be looking for caller ID signaling in the US format, while the UK telephone network would be supplying it (if it is enabled—it is not standard in the UK; you have to pay for caller ID!) in the UK format.
Not only is the format different, but the method of telling a telephone (or Asterisk) to look out for the caller ID may vary from place to place too. This is important, as we do not want Asterisk to waste time looking for caller ID information if it is not being presented on the line.
Again, Asterisk defaults to the
North American caller ID format (no entries in
/etc/asterisk/chan_dahdi.conf
describe this, it’s
just the default), and in order to change it we will need to make some
entries that describe the technical details of the caller ID system. In
the case of the UK, the delivery of caller ID information is signaled by
a polarity reversal on the telephone line (in other words, the A and B
legs of the pair of telephone wires are temporarily switched over), and
the actual caller ID information is delivered in a format known as V.23
(frequency shift keying, or FSK). So, the entries in
chan_dahdi.conf
to receive UK-style caller ID on
any FXO interfaces will look like this:
cidstart=polarity
; the delivery of caller ID will be ; signaled by a polarity reversal cidsignalling=v23
; the delivery of the called ID information ; will be in V23 format
Of course, you may also need to send caller ID using the same local signaling information to any analog phones that are connected to FXS interfaces, and one more entry may be needed as in some locations the caller ID information is sent after a specified number of rings. If this is the case, you can use this entry:
sendcalleridafter=2
Before you can make these
entries, you will need to establish the details of your local caller ID
system (someone from your local telco or Google could be your friend
here, but there is also some good information in the sample
/etc/asterisk/chan_dahdi.conf
file).
As you may know, the prompts (or recordings) that Asterisk
will use are stored in /var/lib/asterisk/sounds/
.
In older versions of Asterisk all the sounds were in this actual
directory, but these days you will find a number of subdirectories that
allow the use of different languages or accents. The names of these
subdirectories are arbitrary; you can call them whatever you
want.
Note that the filenames in
these directories must be what Asterisk is expecting—for example, in
/var/lib/asterisk/sound/en/
the file
hello.gsm
would contain the word “Hello” (spoken by
the lovely Allison), whereas hello.gsm
in
/var/lib/asterisk/sounds/es/
(for Spanish in this
case) would contain the word “Hola” (spoken by the Spanish equivalent of
the lovely Allison[90]).
The default directory used is
/var/lib/asterisk/sounds/en
, so how do you change
that?
There are two ways. One is to
set the language in the channel configuration file that calls are
arriving through using the language
directive. For
example, the line:
language=en_UK
placed in
chan_dahdi.conf
, sip.conf
, and
so on (to apply generally, or for just a given channel or profile) will
tell Asterisk to use sound files found in
/var/lib/asterisk/sounds/en_UK
(which could contain
British-accented prompts) for all calls that come in through those
channels.
The other way is to change the
language during a phone call through the dialplan. This (along with many
attributes of an individual call) can be set using the
CHANNEL()
dialplan function. See Chapter 10, Deeper into the Dialplan for a full
treatment of dialplan functions.
The following example would allow the caller to choose one of three languages in which to continue the call:
; gives the choice of (1) French, (2) Spanish, or (3) German exten => s,1,Background(choose-language) same => n,WaitExten(5) exten => 1,1,Set(CHANNEL(language)=fr) exten => 2,1,Set(CHANNEL(language)=es) exten => 3,1,Set(CHANNEL(language)=de) ; the next priority for extensions 1, 2, or 3 would be handled here exten => _[123],n,Goto(menu,s,1)
If the caller pressed
1
sounds would be played from
/var/lib/asterisk/sounds/fr
, if he pressed
2
the sounds would come from
/var/lib/asterisk/sounds/es
, and so on.
As already mentioned, the names
of these directories are arbitrary and do not need to be only two
characters long—the main thing is that you match the name of the
subdirectory you have created in the language
directive in the channel configuration, or when you set the
CHANNEL(language)
argument in the dialplan.
Asterisk uses the Linux system time from the host server, as you would expect, but we may have users of the system who are in different time zones, or even in different countries. Voicemail is where the rubber hits the road, as this is where users come into contact with time/date stamp information.
Consider a scenario where some users of the system are based in the US, while others are in the UK.
As well as the time difference, another thing to consider is the way people in the two locations are used to hearing date and time information—in the US, dates are usually ordered month, day, year and times are specified in 12-hour clock format (e.g., 2:54 P.M.).
In contrast, in the UK, dates are ordered day, month, year and times are often specified in 24-hour clock format (14:54 hrs)—although some people in the UK prefer 12-hour clock format, so we will cover that too.
Since all these things are
connected to voicemail, you would be right to guess that we configure it
in /etc/asterisk/voicemail.conf
—specifically, in
the [zonemessages]
section of the file.
Here is the
[zonemessages]
part of the sample
voicemail.conf
file that comes with Asterisk, with
UK24
(for UK people that like 24-hour clock format
times) and UK12
(for UK people that prefer 12-hour
clock format) zones added:
[zonemessages] ; Users may be located in different timezones, or may have different ; message announcements for their introductory message when they enter ; the voicemail system. Set the message and the timezone each user ; hears here. Set the user into one of these zones with the tz=attribute ; in the options field of the mailbox. Of course, language substitution ; still applies here so you may have several directory trees that have ; alternate language choices. ; ; Look in /usr/share/zoneinfo/ for names of timezones. ; Look at the manual page for strftime for a quick tutorial on how the ; variable substitution is done on the values below. ; ; Supported values: ; 'filename' filename of a soundfile (single ticks around the filename ; required) ; ${VAR} variable substitution ; A or a Day of week (Saturday, Sunday, ...) ; B or b or h Month name (January, February, ...) ; d or e numeric day of month (first, second, ... thirty-first) ; Y Year ; I or l Hour, 12 hour clock ; H Hour, 24 hour clock (single digit hours preceded by "oh") ; k Hour, 24 hour clock (single digit hours NOT preceded by "oh") ; M Minute, with 00 pronounced as "o'clock" ; N Minute, with 00 pronounced as "hundred" (US military time) ; P or p AM or PM ; Q "today", "yesterday" or ABdY ; (*note: not standard strftime value) ; q " (for today), "yesterday", weekday, or ABdY ; (*note: not standard strftime value) ; R 24 hour time, including minute ; eastern=America/New_York|'vm-received' Q 'digits/at' IMp central=America/Chicago|'vm-received' Q 'digits/at' IMp central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours' military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p' european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM UK24=Europe/London|'vm-received' q 'digits/at' H N 'hours' UK12=Europe/London|'vm-received' Q 'digits/at' IMp
These zones not only specify a time, but also dictate the way times and dates are ordered and read out.
Having created these zones, we
can go to the voicemail context part of
voicemail.conf
to associate the appropriate
mailboxes with the correct zones:
[default] 4001 => 1234,Russell Bryant,rb@shifteight.org,,|tz=central 4002 => 4444,David Duffett,dd@shifteight.org,,|tz=UK24 4003 => 4450,Mary Poppins,mp@shifteight.org,,|tz=UK12|attach=yes
As you can see, when we declare a mailbox, we also (optionally) associate it with a particular zone. Full details on voicemail can be found in Chapter 8, Voicemail.
The last thing to localize in our Asterisk configuration is the tones played to callers by Asterisk once they are inside the system (e.g., the tones a caller hears during a transfer).
As identified earlier in this chapter, the initial tones that people hear when they are calling into the system will come from the IP phone, or from DAHDI for analog channels.
These tones are set in
/etc/asterisk/indications.conf
. Here is a part of
the sample file, where you can see a given region specified by the
country
directive. We just need to change the country
code as appropriate:
; ; indications.conf ; ; Configuration file for location specific tone indications ; ; NOTE: ; When adding countries to this file, please keep them in alphabetical ; order according to the 2-character country codes! ; ; The [general] category is for certain global variables. ; All other categories are interpreted as location specific indications ; [general] country=uk ; default is US, so we have changed it to UK
Your dialplan will need to
reflect the numbering scheme for your region. If you do not already know
the scheme for your area, your local telecoms regulator will usually be
able to supply details of the plan. Also, the example dialplan in
/etc/asterisk/extensions.conf
is, of course, packed
with North American numbers and patterns.
[90] Who is, in fact, the same Allison who does the English prompts; June Wallack does the French prompts. The male Australian-accented prompts are done by Cameron Twomey. All voiceover talent are available to record additional prompts as well. See http://www.digium.com/en/products/ivr/ for more information.