[asterisk-users] Re: Match a Numer - then continue with dialplan

Tony Mountifield tony at softins.clara.co.uk
Wed Dec 20 11:46:33 MST 2006


In article <645FEC31A18FE54A8721500CDD55A7B60350769C at mail.oneeighty.com>,
Douglas Garstang <dgarstang at oneeighty.com> wrote:
> 
> Don't get offended Doug, but I get really frustrated when I try to explain what I am trying
> to do with Asterisk, and people don't seem to quite get it. Your about the 4th person who's
> replied to this post, and hasn't quite grasped my question. :) <--- smiley.. see...we're all
> cool.

Perhaps its the terminology you used that is confusing people. See below:

> I don't want Asterisk to go on to ask for more digits. I want to do a very simple thing. I
> want to set a variable when call flow continues beyond a certain point (without asking the
> user for more digits), and then continue on, and use that variable later. It's a very simple
> thing, I can't work out why Asterisk doesn't let me do that.

To almost all people "call flow" would mean executing one priority after
another for a given extension.

After reading and re-reading your posts trying to work out what you are
trying to do, it seems to me that when *you* say "call flow", you mean the
act of trying to find an extension. And what your looking for is a way to
do things a different points in the *search*, while it is still trying to
decide on a statement to land on. Is that correct?

If so, I think you need to re-think the strategy a bit. The only way a
command gets executed in a dialplan is when Asterisk has matched an extension
and a priority. Then once it has executed that command, it increments the
priority (unless it was a Goto or something) and starts searching again.

However, don't forget that it searches for matching extensions every time
the priority changes. You are not locked into a particular pattern or
extension number from priority 1 onwards. You can mix and match patterns
with literal extensions, even across includes, e.g.

[example]
include => ctx31X
include => ctx3XX

exten => _X.,1,NoOp(this gets executed first for everything)
exten => _X.,2,NoOp(this gets executed second only if ctx31X or ctx3XX didnt match)
exten => _X.,3,NoOp(this gets executed third for everything)

[ctx31X]
exten => _31X,2,NoOp(this gets executed second for 310-319)

[ctx3XX]
exten => _3XX,2,NoOp(this gets executed second for 300-309 and 320-399)

So you might be able to do something along these lines by being creative
with priorities and includes, and setting or testing variables. Something
along these lines:

1. Each company starts off in its own context, and at priority 1 in _X. it
sets a variable like SRCCOMPANY to something specific to it.
It includes all the destination contexts.

2. Each destination context starts at priority 2 and sets a variable like
DESTCOMPANY to something specific to that destination.

3. At priority 3 in each source context, SRCCOMPANY and DESTCOMPANY are
compared, in order to decide whether to override the CallerID with the
source company's generic callerID. Let's say this uses priorities 3, 4
and 5 (for the GotoIf doing the compare, then the SetCallerID, and the
NoOp target for the GotoIf when the callerID doesn't need rewriting).
The destination contexts do not have priorities 3, 4 and 5.

4. The destination contexts continue at priority 6 to route the call.

I think by interleaving priorities between contxts like this you should
be able to achieve what you are looking for. Please let us know on the list
if you are successful - it encourages us to keep helping in the future!

Hope this helps
Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org


More information about the asterisk-users mailing list