Route IAX call through a call flow but potentially just 'leave it alone'?

I’d like to be able to check IAX calls against a call flow control (day/night check) and if it’s night, send the call to an announcement or IVR. However, if it’s day, I’d like to let the call proceed as dialled, ie to whichever extension the caller wanted to reach. I can’t think how to do this. What would the option be for “continue as before”, please?
Thank you!

Would that be an internal or external call? If external, just replace the current destination in the inbound route to a call flow with your logic. If internal, you are up for custom code.

1 Like

Thanks. It’s IAX. So I guess ‘internal’ ?

IAX can be used both internally and externally. What I meant is if you want this for calls that come from the exterior, like PSTN or trunks, or if you want this for the calls between internal extensions.

Ah. Calls between internal extensions. Basically I run FreePBX on two servers and they’re connected with an IAX trunk.
Extension ranges on one are 5000-5009 and on the other 40-49 (not many extensions on either)

You will have to do it manually with custom code I think, call flows work with external calls out of the box.

I am assuming you have set up the IAX trunk with context “from-internal” based on the scenario you described. In this context the extensions will take priority.

Try this!

Admin - Custom Destinations: create one that looks like this:

Then set up your time condition:

Now you have a time condition that will route to the dialed extension during day hours, and route to an announcement during night hours. The next thing to do is direct your IAX trunk to it.

Edit /etc/asterisk/extensions_custom.conf and add this at the top or bottom:

exten => _X.,1,Goto(timeconditions,1,1)

What is important here is the first “1” after “timeconditions”. To figure out what number to place there, you look at the URL in FreePBX when you are at the screen where you would edit that time condition. On mine, the URL is /admin/config.php?display=timeconditions&view=form&itemid=1 and the “1” comes from the itemid= at the end. If yours says itemid=5 then in your custom file you would put “timeconditions,5,1”

Finally edit your IAX trunk and where it says “context=from-internal” change that to “context=from-iax-partner-pbx”.

Last note: this assumes you are only sending extension-to-extension traffic across the trunk. The time condition will intercept everything. If you want to be more selective you just edit the custom from-iax-partner-pbx context to match the extension range and go to the time condition, and match other patterns and go to from-internal or whatever makes sense in your environment.


So. Cool. This looks like it will do EXACTLY what I wanted. Fantastic! Thank you! Thanks also to @arielgrin for your support.

@billsimon, initially I thought on first glance that I would not need to be more selective as you mention in your note, but I think ultimately I might want to be, in the future, when my PBX is ‘doing more’ than it does now…I have grand plans.

Thank you

1 Like

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