Page 171 - Asterisk™: The Future of Telephony
P. 171

When we include other contexts within our current context, we have to be mindful of
               the order in which we are including them. Asterisk will first try to match the dialed
               extension in the current context. If unsuccessful, it will then try the first included con-
               text (including any contexts included in that context), and then continue to the other
               included contexts in the order in which they were included.
               As it sits, our current dialplan has two contexts for outbound calls, but there’s no way
               for people in the [employees] context to use them. Let’s remedy that by including the
               two outbound contexts in the [employees] context, like this:
                   [globals]
                   JOHN=Zap/1
                   JANE=SIP/Jane
                   OUTBOUNDTRUNK=Zap/4
                   [incoming]
                   exten => 123,1,Answer()
                   exten => 123,n,Background(enter-ext-of-person)
                   exten => 123,n,WaitExten()
                   exten => 1,1,Dial(${JOHN},10)
                   exten => 1,n,Playback(vm-nobodyavail)
                   exten => 1,n,Hangup()
                   exten => 2,1,Dial(${JANE},10)
                   exten => 2,n,Playback(vm-nobodyavail)
                   exten => 2,n,Hangup()
                   exten => i,1,Playback(pbx-invalid)
                   exten => i,n,Goto(incoming,123,1)

                   exten => t,1,Playback(vm-goodbye)
                   exten => t,n,Hangup()
                   [employees]
                   include => outbound-local
                   include => outbound-long-distance
                   exten => 101,1,Dial(${JOHN})
                   exten => john,1,Dial(${JOHN})
                   exten => 102,1,Dial(${JANE})
                   exten => jane,1,Dial(${JANE})
                   [outbound-local]
                   exten => _9NXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN:1})
                   exten => _9NXXXXXX,n,Congestion()
                   exten => _9NXXXXXX,n,Hangup()
                   exten => 911,1,Dial(${OUTBOUNDTRUNK}/911)
                   exten => 9911,1,Dial(${OUTBOUNDTRUNK}/911)

                   [outbound-long-distance]
                   exten => _91NXXNXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN:1})



                                                                Building an Interactive Dialplan | 143
   166   167   168   169   170   171   172   173   174   175   176