Inbound Route - Look Ahead

Asterisk/FreePBX13

I expect I would be doing the below in the custom.conf, I’m just looking more for the “how to reference”

Is there a way to have in my dial plan a way to check if a route exists in prior to taking an action? I have users that will be adding inbound routes over time and I want to make something that is smart enough to essentially check ext-did-0001 and ext-did-0002 to see if a pattern/number exists. If it exists, I would take one action in the treatment, if it did not, I would take another action.

I would also do something similar for callerID in another step.

Thanks for any guidance here.

Okay I am a little further along, I haven’t been able to “look ahead”.

The new problem I am trying to solve is how do I loop a call, mid-process, so that the call goes through the inbound routes again? During the call I set the DNID to 999999 and set a special callerID 111111. I have a misc destination that will dial the DNID (999999). I have an inbound route (111111/_XXXXXX) that matches this pattern, but I cannot get to it.

I saw a few posts by @SkykingOH that talked about a loopback trunk for going around, but it didn’t work for me when I tried any of the following custom dial strings:
Local/$OUTNUM$@ext-did-0001
Local/$OUTNUM$@ext-did
Local/$OUTNUM$@from-internal

This is the last piece I need to complete the program, but I am stuck. Any ideas on how I can get a call to go back to the inbound route context so that it can reach the last leg of the treatment? @dicko or @cynjut, have either of you done something like this before?

Any ideas would be greatly appreciated!

Have you tried the ‘custom */misc *’ stuff? It seems to me that setting up a misc destination or custom extension should get you pretty close.

Dialplan function:

4693894*CLI> core show function DIALPLAN_EXISTS

  -= Info about function 'DIALPLAN_EXISTS' =-

[Synopsis]
Checks the existence of a dialplan target.

[Description]
This function returns '1' if the target exits. Otherwise, it returns '0'.

[Syntax]
DIALPLAN_EXISTS(context[,extension[,priority]])

[Arguments]
Not available

[See Also]
Not available
1 Like

Thanks Lorne, If you have time for one more question…

How would I enter this with the CallerID check as well? Under the [ext-did-0001] context, it shows up as:
exten => 111111/_XXXXXX,1,

An excellent question. I have never had occasion to test that use case, so I can’t answer. You might try asking in the Asterisk forum as well, you are going to need a dialplan expert.

2 Likes

Good idea, I will see what turns up on that side.

@lgaetz, side question, if I point a call at [ext-did] will it go through a process similar to when I receive a new call from the carrier? Will it check the inbound routes for a matching pattern based on CID/DID and route on a match?

It may, but if you use ‘from-trunk’ then it will.

1 Like

@lgaetz where is the ‘from-trunk’ context? I see it referenced in the extensions_additional.conf but I do not see the actual context.

If I wanted to try a goto ‘ext-did’ to see if that would work, how would I write that? I do not see a step one or extension.

[ext-did]
include => ext-did-0001
include => ext-did-0002
exten => foo,1,Noop(bar)

exten => s,n,Goto(ext-did,1)? What’s missing?

# grep "\[from-trunk\]" /etc/asterisk/*
/etc/asterisk/extensions.conf:[from-trunk]

Goto args are context, exten,priority so it would be:

Goto(ext-did,<DID>,1)

From the Asterisk console, you can get help on any application with:

CLI> core show application goto

  -= Info about application 'Goto' =-

*snip*

[Syntax]
Goto([[context,]extensions,]priority)
1 Like

Thanks, I’ve looks at that and am still learning, so I appreciate the help :slight_smile:

ext-did is new to me but when I reference:

Goto(ext-did,<DID>,1)

I’m confused, because I haven’t used it in this way.

I have the following dial plan:

exten => s,1,GotoIf($["${CHANNEL(state)}" = "Up"]?begin)
exten => s,n,Answer
exten => s,n(begin),Noop(Parsing DID, CID and App into L,Q,T)
exten => s,n,Set(L=${CALLERID(dnid)1:3})
exten => s,n,Set(Q=${CALLERID(num)})
exten => s,n,Set(T=${CALLERID(dnid):0:3})
exten => s,n,Noop(Check Addressbook for entry)
exten => s,n,Set(FAXCHECK=${DB_EXISTS(cidname/${L})})
exten => s,n,GotoIf($["${DB_RESULT}" = "FAX"]?faxpath)
exten => s,n,Noop(Fax number not found, moving to next step)

For the next step I would like to send it to the [ext-did] context, which looks like:

[ext-did]
include => ext-did-0001
include => ext-did-0002
exten => foo,1,Noop(bar)

My goal is that I am trying to use the logic that exists in the inbound routes to screen calls. After a series of checks in my custom context I have a catch all inbound route in the GUI.

I want to give admins a way to “screen” calls simply by adding a specific inbound route in the GUI. If there is a match, use their inbound route, otherwise it filters to my catch-all. My thought was if I could send a call back though the inbound route module, it would be an easy way to manage the additional admin screens.

Is it enough to literally write “Goto(ext-did,,1)” as the next step in my custom context?

I think it would be “Goto(ext-did,foo,1)”, or “Goto(ext-did,s,1)” but yeah.

Dave,

Rather than extensions_custom.conf, do you know if I would be able to achieve a similar affect with a custom trunk and a outbound route with a matching pattern (send the call back to the inbound route logic [from-trunk] via the GUI), then that would be the most preferred. The less I do custom, the easier it will be for others to follow via the GUI down the road.

If you set up a “loop back” trunk, you should be able to do thid. You should also be able to manage your custom contexts from the GUI, so you can try the trunk and set it up in the Misc Dest, et al modules.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.