Re: [asterisk-users] Simplifying dial-plan

2010-12-23 Thread Stephen Reese
> To answer your first question - ${MACRO_EXTEN} is a macro-specific
> variable.  It's the ${EXTEN} that called the macro, since using ${EXTEN}
> inside a Macro would just give you a value of "s".
>
> As for your second question, that's pretty easy to do.  If every outbound
> call needs to be formatted in the format 1NXXNXX, you would do this
> (again, untested, but should be good along with the macro I gave you
> earlier):
>
> [globals]
> DEFAULT_AREA_CODE=555 ; swap with your default area code
>
> [outbound-context]
>
> exten => _1NXXNXX,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
> exten => _NXXNXX,1,Goto(outbound-context,1${EXTEN},1)
> exten => _NXX,1,Goto(outbound-context,1${DEFAULT_AREA_CODE}${EXTEN},1)
> exten => _011.,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
> exten => 911,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
>
>
> --
> Thanks,
> --Warren Selby, dCAP
> http://www.selbytech.com

Thanks again Warren, that works quite well!

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Simplifying dial-plan

2010-12-22 Thread Warren Selby
On Wed, Dec 22, 2010 at 10:12 PM, Stephen Reese  wrote:

> Thanks Warren, that's what I'm looking to do.
>
> First question is where did ${MACRO_EXTEN} come from, I assumed
> ${EXTEN} is a built in variable?
>
> Secondly, where would the 1 and/or area-code need to be placed? Could
> an additional argument be used to specify the prefix, i.e. a third
> variable be specified in the outbond-context to implement the
> OutboundDial macro, or is the MACRO_EXTEN suppose to be an
> implementation of this?
>
> exten => s,n,Dial(SIP/{$arg3}${macro_ext...@vitel-outbound2)
>
> As Jeroen mentioned previously a goto may be used, would this help,
> seems similar to what I am trying to accomplish.
>
> exten => _NXXNXX,1,Goto(1${EXTEN},1)
> exten => _NXX,1,Goto(1555${EXTEN},1)
>
>
>
To answer your first question - ${MACRO_EXTEN} is a macro-specific
variable.  It's the ${EXTEN} that called the macro, since using ${EXTEN}
inside a Macro would just give you a value of "s".

As for your second question, that's pretty easy to do.  If every outbound
call needs to be formatted in the format 1NXXNXX, you would do this
(again, untested, but should be good along with the macro I gave you
earlier):

[globals]
DEFAULT_AREA_CODE=555 ; swap with your default area code

[outbound-context]

exten => _1NXXNXX,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
exten => _NXXNXX,1,Goto(outbound-context,1${EXTEN},1)
exten => _NXX,1,Goto(outbound-context,1${DEFAULT_AREA_CODE}${EXTEN},1)
exten => _011.,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
exten => 911,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})


-- 
Thanks,
--Warren Selby, dCAP
http://www.selbytech.com
--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Simplifying dial-plan

2010-12-22 Thread Stephen Reese
On Wed, Dec 22, 2010 at 12:59 PM, Warren Selby  wrote:
> On Tue, Dec 21, 2010 at 6:59 PM, Stephen Reese  wrote:
>>
>> On Tue, Dec 21, 2010 at 7:58 PM, Stephen Reese  wrote:
>> > Is there a way to include:
>> >
>> > _NXXNXX
>> > _NXX
>> > _011.
>> > _911
>> >
>> > into my current plan:
>> >
>>
>> Sorry, here's the rest.
>>
>> exten => _1NXXNXX,1,Set(Outgoing=${CUT(CHANNEL,/,2)})
>> exten => _1NXXNXX,n,Set(Outgoing=${CUT(Outgoing,-,1)})
>> exten => _1NXXNXX,n,GotoIf($["${Outgoing}" = "201"]?20:10)
>> exten => _1NXXNXX,10,Set(CALLERID(all)=${EXTERNAL_CALLERID})
>> exten => _1NXXNXX,n,Dial(SIP/${ext...@vitel-outbound)
>> exten => _1NXXNXX,n,Goto(h,1)
>> exten => _1NXXNXX,20,Set(CALLERID(all)=${EXTERNAL_CALLERID})
>> exten => _1NXXNXX,n,Dial(SIP/${ext...@vitel-outbound2)
>> exten => _1NXXNXX,n,Goto(h,1)
>>
>
> Why not make a Macro (or GoSub) to handle this block of code, and then your
> outbound dial lines are just one line calling the Macro?  Saves a lot of
> repeating blocks of code. Something like this (not tested):
>
> [macro-OutboundDial]
> ; ${ARG1} = CHANNEL
> ; ${ARG2} = EXTERNAL_CALLERID
> exten => s,1,Set(Outgoing=${CUT(${ARG1},/,2)})
> exten => s,n,Set(Outgoing=${CUT(Outgoing,-,1)})
> exten => s,n,GotoIf($["${Outgoing}" = "201"]?outbound2:outbound1)
> exten => s,n(outbound1),Set(CALLERID(all)=${ARG2})
> exten => s,n,Dial(SIP/${macro_ext...@vitel-outbound)
> exten => s,n,Goto(h,1)
> exten => s,n(outbound2),Set(CALLERID(all)=${ARG2})
> exten => s,n,Dial(SIP/${macro_ext...@vitel-outbound2)
> exten => s,n,Goto(h,1)
>
> [outbound-context]
>
> exten => _NXXNXX,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
> exten => _NXX,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
> exten => _011.,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
> exten => _911,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
>
>
> --
> Thanks,
> --Warren Selby, dCAP
> http://www.selbytech.com

Thanks Warren, that's what I'm looking to do.

First question is where did ${MACRO_EXTEN} come from, I assumed
${EXTEN} is a built in variable?

Secondly, where would the 1 and/or area-code need to be placed? Could
an additional argument be used to specify the prefix, i.e. a third
variable be specified in the outbond-context to implement the
OutboundDial macro, or is the MACRO_EXTEN suppose to be an
implementation of this?

exten => s,n,Dial(SIP/{$arg3}${macro_ext...@vitel-outbound2)

As Jeroen mentioned previously a goto may be used, would this help,
seems similar to what I am trying to accomplish.

exten => _NXXNXX,1,Goto(1${EXTEN},1)
exten => _NXX,1,Goto(1555${EXTEN},1)

Thanks,
Stephen

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Simplifying dial-plan

2010-12-22 Thread Warren Selby
On Tue, Dec 21, 2010 at 6:59 PM, Stephen Reese  wrote:

> On Tue, Dec 21, 2010 at 7:58 PM, Stephen Reese  wrote:
> > Is there a way to include:
> >
> > _NXXNXX
> > _NXX
> > _011.
> > _911
> >
> > into my current plan:
> >
>
> Sorry, here's the rest.
>
> exten => _1NXXNXX,1,Set(Outgoing=${CUT(CHANNEL,/,2)})
> exten => _1NXXNXX,n,Set(Outgoing=${CUT(Outgoing,-,1)})
> exten => _1NXXNXX,n,GotoIf($["${Outgoing}" = "201"]?20:10)
> exten => _1NXXNXX,10,Set(CALLERID(all)=${EXTERNAL_CALLERID})
> exten => _1NXXNXX,n,Dial(SIP/${ext...@vitel-outbound)
> exten => _1NXXNXX,n,Goto(h,1)
> exten => _1NXXNXX,20,Set(CALLERID(all)=${EXTERNAL_CALLERID})
> exten => _1NXXNXX,n,Dial(SIP/${ext...@vitel-outbound2)
> exten => _1NXXNXX,n,Goto(h,1)
>
>
Why not make a Macro (or GoSub) to handle this block of code, and then your
outbound dial lines are just one line calling the Macro?  Saves a lot of
repeating blocks of code. Something like this (not tested):

[macro-OutboundDial]
; ${ARG1} = CHANNEL
; ${ARG2} = EXTERNAL_CALLERID
exten => s,1,Set(Outgoing=${CUT(${ARG1},/,2)})
exten => s,n,Set(Outgoing=${CUT(Outgoing,-,1)})
exten => s,n,GotoIf($["${Outgoing}" = "201"]?outbound2:outbound1)
exten => s,n(outbound1),Set(CALLERID(all)=${ARG2})
exten => s,n,Dial(SIP/${macro_ext...@vitel-outbound)
exten => s,n,Goto(h,1)
exten => s,n(outbound2),Set(CALLERID(all)=${ARG2})
exten => s,n,Dial(SIP/${macro_ext...@vitel-outbound2)
exten => s,n,Goto(h,1)

[outbound-context]

exten => _NXXNXX,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
exten => _NXX,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
exten => _011.,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})
exten => _911,1,Macro(OutboundDial,${CHANNEL},${EXTERNAL_CALLERID})


-- 
Thanks,
--Warren Selby, dCAP
http://www.selbytech.com
--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Simplifying dial-plan

2010-12-22 Thread Jeroen Eeuwes
Hi Stephen,

> Jeroen, I'm trying to avoid rewriting the outgoing block for the
> patterns mentioned above. I've placed a pseudo dial-plan below. The
> plan needs to dial the 1 and/or also the area code depending on the
> pattern they enter. Any tips, thanks.

I find a diaplan much easier to read if all the lines of the same
"exten => pattern,x,etc" are grouped. The way you showed it now is
very difficult to read.

What you could do is something like this

exten => _NXXNXX,1,Goto(1${EXTEN},1)
exten => _NXX,1,Goto(1555${EXTEN},1)

Assuming that you want to dial an 1 if not dialed first and you've got
10 digits or if you only receive 7 digits you want to add both an 1
and "areacode" 555.

Because you've added the extra digits yourself it will match to the
_1NXXNXX extension and start there at 1.

Best regards,
Jeroen Eeuwes

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Simplifying dial-plan

2010-12-22 Thread Stephen Reese
On Wed, Dec 22, 2010 at 2:01 AM, Jeroen Eeuwes  wrote:
> Hi Stephen,
>
>> _NXXNXX
>> _NXX
>> _011.
>> _911
>
> Of course it can, but it depends on what you want to do when those
> numbers are called...
>
> I didn't know about the setvar in the sip.conf and actually I think it
> is a much "cleaner" solution. Since you are already using it I would
> suggest to not only use it for CallerID but also for the
> @vitel-outbound like this:
>
> exten => _1NXXNXX,1,Set(CALLERID(all)=${EXTERNAL_CALLERID})
> exten => _1NXXNXX,n,Dial(SIP/${ext...@${outbound})
> exten => _1NXXNXX,n,Goto(h,1)
>
> Of course you'll need to set setvar=Outbound=vitel-outbound or
> setvar=Outbound=vitel-outbound2 in sip.conf.
>
> What do you want to do with the other numbers? If you want to do the
> same as with _1NXXNXX you can just add things like this in your
> extensions.conf:
>
> exten => _NXXNXX,1,Goto(_1NXXNXX,1)
> exten => 911,1,Goto(_1NXXNXX,1)
>
> Or you can do different things if you want that like this:
>
> exten => _NXX,1,Set(CALLERID(all)="No one cares" <0>)
> exten => _NXX,n,Dial(SIP/${ext...@abcdefgh)
> exten => _NXX,n,Goto(h,1)
>
> Best regards,
> Jeroen Eeuwes

Jeroen, I'm trying to avoid rewriting the outgoing block for the
patterns mentioned above. I've placed a pseudo dial-plan below. The
plan needs to dial the 1 and/or also the area code depending on the
pattern they enter. Any tips, thanks.

exten => _1NXXNXX,1,Set(Outgoing=${CUT(CHANNEL,/,2)})
exten => _1NXXNXX,n,Set(Outgoing=${CUT(Outgoing,-,1)})
exten => _1NXXNXX,n,GotoIf($["${Outgoing}" = "201"]?20:10)
exten => _1NXXNXX,10,Set(CALLERID(all)=${EXTERNAL_CALLERID})
exten => _NXXNXX,10,Set(CALLERID(all)=${EXTERNAL_CALLERID})
exten => _NXX,10,Set(CALLERID(all)=${EXTERNAL_CALLERID})
exten => _1NXXNXX,n,Dial(SIP/${ext...@vitel-outbound)
exten => _NXXNXX,n,Dial(SIP/${ext...@vitel-outbound)
exten => _NXX,n,Dial(SIP/${ext...@vitel-outbound)
exten => _1NXXNXX,n,Goto(h,1)
exten => _NXXNXX,n,Goto(h,1)
exten => _NXX,n,Goto(h,1)
exten => _1NXXNXX,20,Set(CALLERID(all)=${EXTERNAL_CALLERID})
exten => _1NXXNXX,n,Dial(SIP/${ext...@vitel-outbound2)
exten => _1NXXNXX,n,Goto(h,1)

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Simplifying dial-plan

2010-12-21 Thread Jeroen Eeuwes
Hi Stephen,

> _NXXNXX
> _NXX
> _011.
> _911

Of course it can, but it depends on what you want to do when those
numbers are called...

I didn't know about the setvar in the sip.conf and actually I think it
is a much "cleaner" solution. Since you are already using it I would
suggest to not only use it for CallerID but also for the
@vitel-outbound like this:

exten => _1NXXNXX,1,Set(CALLERID(all)=${EXTERNAL_CALLERID})
exten => _1NXXNXX,n,Dial(SIP/${ext...@${outbound})
exten => _1NXXNXX,n,Goto(h,1)

Of course you'll need to set setvar=Outbound=vitel-outbound or
setvar=Outbound=vitel-outbound2 in sip.conf.

What do you want to do with the other numbers? If you want to do the
same as with _1NXXNXX you can just add things like this in your
extensions.conf:

exten => _NXXNXX,1,Goto(_1NXXNXX,1)
exten => 911,1,Goto(_1NXXNXX,1)

Or you can do different things if you want that like this:

exten => _NXX,1,Set(CALLERID(all)="No one cares" <0>)
exten => _NXX,n,Dial(SIP/${ext...@abcdefgh)
exten => _NXX,n,Goto(h,1)

Best regards,
Jeroen Eeuwes

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


[asterisk-users] Simplifying dial-plan

2010-12-21 Thread Stephen Reese
Is there a way to include:

_NXXNXX
_NXX
_011.
_911

into my current plan:

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Simplifying dial-plan

2010-12-21 Thread Stephen Reese
On Tue, Dec 21, 2010 at 7:58 PM, Stephen Reese  wrote:
> Is there a way to include:
>
> _NXXNXX
> _NXX
> _011.
> _911
>
> into my current plan:
>

Sorry, here's the rest.

exten => _1NXXNXX,1,Set(Outgoing=${CUT(CHANNEL,/,2)})
exten => _1NXXNXX,n,Set(Outgoing=${CUT(Outgoing,-,1)})
exten => _1NXXNXX,n,GotoIf($["${Outgoing}" = "201"]?20:10)
exten => _1NXXNXX,10,Set(CALLERID(all)=${EXTERNAL_CALLERID})
exten => _1NXXNXX,n,Dial(SIP/${ext...@vitel-outbound)
exten => _1NXXNXX,n,Goto(h,1)
exten => _1NXXNXX,20,Set(CALLERID(all)=${EXTERNAL_CALLERID})
exten => _1NXXNXX,n,Dial(SIP/${ext...@vitel-outbound2)
exten => _1NXXNXX,n,Goto(h,1)

Thanks

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users