[asterisk-users] dial out with channel variable; sub-string usage

Chad Wallace cwallace at lodgingcompany.com
Thu Apr 9 14:06:12 CDT 2015

On Wed, 08 Apr 2015 16:10:30 -0700
thufir <hawat.thufir at gmail.com> wrote:

> I want to do something like:
> exten => _NXXXNxxxxxx,1,Dial(${BABY}/${EXTEN})
> exten => _Nxxxxxx,1,Dial(${BABY}/${EXTEN})
> exten => _1NXXNxxxxxx,1,Dial(${BABY}/${EXTEN})
> exten => _011.,1,Dial(Dial({TOLL}/${EXTEN})
> exten => _9NXXXNxxxxxx,1,Dial(${BABY}/${EXTEN})
> exten => _9Nxxxxxx,1,Dial(${BABY}/${EXTEN})
> exten => _91NXXNxxxxxx,1,Dial(${BABY}/${EXTEN})
> exten => _9011.,1,Dial(Dial({TOLL}/${EXTEN})
> (adapted from the book)
> but don't know where to put those lines.  I have BABY defined as
> channel variable:
> BABY = SIP/babytel_out
> but that seems circular, somehow.

You put them in the context for your clients... From what you show
below, I'd say they go in the "local_200" context.  You can verify
this by looking in sip.conf, in the section that starts with [200],
find the line that starts with "context=".  It's probably
"context=local_200".  Then you put the outbound dialplan in that context
in extensions.conf.  Mind you, then 200 is the only phone that can dial
out.  201 can only dial 200 and nothing else.

One suggestion...  those 8 lines are redundant.  The first 4 let you
dial out without the 9 in front, and the last 4 need you to dial 9 to
get out.  You should probably decide which way you want to do it, and
use only 4 of the lines instead of 8.  Keep it simple.  Also, if you
don't use 7-digit dialing in your area, you can drop the second line
(_Nxxxxxx) and only have 3.  

Mind you, even if your local area supports 7-digit dialing, I'm
guessing babytel doesn't, so it wouldn't even work like that.  You
would have to add your area code (or 1 and your area code) after the
slash between ${BABY} and ${EXTEN}, just on that one line.

> inbound calls work fine:
> [inbound-calls]
>   exten => 16046289850,1,Dial(SIP/200)
> [local_200]
> exten => _9x.,1,Set(CALLERID(all)="Ali Baba" <123456789>)
> exten => _9x.,1,Dial(SIP/${EXTEN:1}@babytel_out)
> exten => 201,1,Dial(SIP/201)
> [local_201]
> exten => 200,1,Dial(SIP/200)
> in local_200, that just seems suspect.  Yes, dial out, but shouldn't
> it be using BABY?  I don't understand why it's using sub-string with
> the 1.

That's a different syntax for the same thing.  These three lines all do
the same thing:

exten => _9x.,1,Dial(SIP/${EXTEN:1}@babytel_out)


exten => _9x.,1,Dial(SIP/babytel_out/${EXTEN:1})


exten => _9x.,1,Dial(${BABY}/${EXTEN:1})

The ${EXTEN:1} strips off the "9" at the front of EXTEN, because babytel
doesn't want to get the 9 that you dial on the phone.  If you go with
dialing without the 9, you'll use ${EXTEN}, not ${EXTEN:1}.


C. Chad Wallace, B.Sc.
The Lodging Company
OpenPGP Public Key ID: 0x262208A0

More information about the asterisk-users mailing list