Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Building Telephony Systems With Asterisk (2005).pdf
Скачиваний:
45
Добавлен:
17.08.2013
Размер:
1.82 Mб
Скачать

Chapter 8

As we can see, configuring voicemail is simple. The important thing to remember is that whatever we set the name to determines whether an extension will match an entry in the Directory. Also, the context in voicemail should always match the context in extensions.conf.

extensions.conf

[general]

static=yes

writeprotect=no

#include macros.incl #include incoming.incl #include outgoing.incl #include default.incl #include dialext.incl

[globals]

TRUNK=Zap/g1

TRUNKMSD=1

This is our entire extensions.conf file. By using the #include feature, we are able to make our configuration files much easier to read, and much easier to maintain. We should remember to keep the filenames easy to read and logical. Since each of these files is included into the extensions.conf file, they will not get separate sections in this chapter.

;macros.incl

;#included into extensions.conf [macro-stdexten]

;

;Standard extension macro:

;${ARG1} - Extension (we could have used ${MACRO_EXTEN} here as

;

well)

 

 

 

 

; ${ARG2} - Device(s) to ring

 

 

 

 

;

 

 

 

 

 

exten => s,1,Dial(${ARG2},20)

;

Ring

the interface, 20 seconds

 

 

;

maximum

exten => s,2,Goto(s-${DIALSTATUS},1) ;

Jump

based on status

exten => s-NOANSWER,1,Voicemail(u${ARG1})

;

If unavailable, send to

 

 

 

 

;

voicemail

exten => s-NOANSWER,2,Goto(default,0,1)

 

;

If they press #, go to

 

 

 

 

;

Operator

exten => s-BUSY,1,Voicemail(b${ARG1})

 

; If

busy, send to voicemail

 

 

 

;

with busy message

exten => s-BUSY,2,Goto(default,0,1)

 

; If

they press #, go to

 

 

 

;

Operator

exten => s-CHANUNAVAIL,1,Voicemail(u${ARG1}) exten => s-CHANUNAVAIL,2,Goto(default,0,1)

exten => s-.,1,Goto(s-NOANSWER,1)

;Treat anything else as no

;answer

125

Case Studies

exten => a,1,VoicemailMain(${ARG1}) ;

If they press *, send to

;

VoicemailMain

[macro-novm]

exten => s,1,Dial(${ARG1},30) ;ring the interface for 30 seconds exten => s,2,Goto(default,s,1)

exten => s,102,Goto(default,s,1)

Notice that we have a macro to set up all of the extensions we will be creating. This will save us a ton of work later on, as well as make our configuration files very readable.

;incoming.incl

;#included from extensions.conf [incoming]

exten => 5555551234,1,Goto(default,100,1) ;Main number rings to ; Operators

exten => 5555552345,1,Goto(default,110,1) ;Direct number to Support

exten => 5551110001,1,Goto(default,111,1) ;Direct line

to

;

Extension

111

exten => 5551110002,1,Goto(default,112,1) ;Direct line

to

;

Extension

112

exten => 5551110003,1,Goto(default,113,1) ;Direct line

to

;

Extension

113

. . .

 

 

exten => s,1,Goto(default,100,1);

 

 

exten => t,1,Goto(default,100,1);

 

 

exten => i,1,Goto(default,100,1);

 

 

Notice that we handle all incoming calls via this file. Here we define our DIDs and where we want them to ring. We also make sure to create intelligent rules in case the DID information is mangled by our phone company before Asterisk can decode it. In this case, we are sending the calls to our Operator.

; outgoing.incl

;#included from extensions.conf [local]

ignorepat => 9

exten => _9NXXXXXX,1,Goto(trunkdial,${EXTEN},1) exten => _91800XXXXXXX,1,Goto(trunkdial,${EXTEN},1) exten => _91866XXXXXXX,1,Goto(trunkdial,${EXTEN},1) exten => _91877XXXXXXX,1,Goto(trunkdial,${EXTEN},1) exten => _91888XXXXXXX,1,Goto(trunkdial,${EXTEN},1) include => default

[longdistance] ignorepad => 9

exten => _91NXXNXXXXXX,1,Goto(trunkdial,${EXTEN},1) include => local

[trunkdial]

exten => _9.,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}}) exten => _9.,2,Congestion(5)

exten => _9.,3,Hangup

Notice what we have done here: we created a general context called trunkdial, which we use to dial any calls going over the trunk lines. Why is this helpful? If we were to add a new trunk group, we could add only one line. If we were to use the standard method of having each line above dial, we would have to add six lines for each new trunk group.

126

Chapter 8

This example assumes we will have no users placed directly in the trunkdial context, such as in the sip.conf file. For security reasons, we must be careful that we do not ever place a user explicitly in the trunkdial context.

;default.incl

;#included in extensions.conf [default]

exten => s,1,Goto(default,100,1) exten => t,1,Goto(default,100,1) exten => i,1,Goto(default,100,1)

; Operator queue, Operator Console, and Receptionist Phone

exten =>

100,1,Answer

 

 

exten =>

100,2,Queue(Q100||||240)

; only allow 4 minutes in queue

exten =>

100,3,Voicemail(u100)

;

then send to VM

exten =>

_10[12],1,Macro(stdexten,${EXTEN},SIP/${EXTEN})

;Support

Tier 1

 

 

exten =>

110,1,Answer

 

 

exten =>

110,2,Queue(Q110||||240)

; allow 4 minutes in queue

exten =>

110,3,Goto(default,100,1) ;

then send to Operator

exten =>

_11[1-4],1,Macro(stdexten,${EXTEN},SIP/${EXTEN})

;Support

Tier 2

 

 

exten =>

120,1,Answer

 

 

exten =>

120,2,Queue(Q120||||240)

; allow 4 minutes in queue

exten =>

120,3,Goto(default,100,1) ;

then send to Operator

exten =>

_12[12],1,Macro(stdexten,${EXTEN},SIP/${EXTEN})

;Support

Tier 3

 

 

exten =>

130,1,Answer

 

 

exten =>

130,2,Queue(Q130||||240)

; allow 4 minutes in queue

exten =>

130,3,Goto(default,100,1) ;

then send to Operator

exten =>

131,1,Macro(stdexten,${EXTEN},SIP/${EXTEN})

;Programmers, extensions 200-219

 

 

exten =>

_2[01]X,1,Macro(stdexten,${EXTEN},SIP/${EXTEN})

;Testers, extensions 251-255

 

 

exten =>

_25[1-5],1,Macro(stdexten,${EXTEN},SIP/${EXTEN})

;Project

Managers, exts 301-304

 

 

exten =>

_30[1-4],1,Macro(stdexten,${EXTEN},SIP/${EXTEN})

;Shipping Department, ext 191, doesn't need voicemail

exten =>

191,1,Macro(novm,SIP/${EXTEN})

exten =>

800,1,Answer

 

 

exten =>

800,2,VoicemailMain

 

 

exten =>

_85X,1,Answer

 

 

exten =>

_85X,2,MeetMe(${EXTEN})

 

 

exten =>

888,1,Goto(dialext,s,1)

 

 

127