Dynamic Routing with MySQL

Hi,
I am quite happy with our FreePBX. However I have one Routing problem.
We have 10 Salesguys - Extension 10-20. And some other 2 digit / 4 digit extensions.

Currently I am working with fixed inbound routes - but I would like to route the extensions via a MySQL Database.

So normally 10 => 10, 11 => 11 etc. However in cases of holiday / illness etc. I would like to route 10 => 201 (ringgroup).

I already setup dynamic routing - but do I really have to add all possible outcomes? I wanted to do it with the Number that comes back from the database.

Thanks in advance!
Best regards,
Eric

Here you find the current settings

You can setup a default route for no matches, other than that there needs to be a match. Can you do something more clever, sure, but it depends on your unique use case.

Welcome to the FreePBX community!

You can do this by assigning the dynroute lookup result to an Asterisk channel variable, such as lookup_result. Then create a Custom Destination with the target set to

from-internal,${lookup_result},1

The quick and easy way is now to configure the dynroute only with the default destination set to this new custom destination, no dynamic route entries. The caller will be sent to whatever dial string comes back from the mysql lookup.

To get a more fault tolerant setup, you need a separate Dynamic Route entry for each acceptable reply back from the mysql, and branch the call to the appropriate destination without using the custom destination. That way the default destination can be used to send the caller to an acceptable place if the sql returns a value that is bad or fails to return a value at all.

3 Likes

Thanks - that seems pretty helpful. However I integrated this solution and the variable is somehow not transmitted.

“Dial failed due to trunk reporting Address Incomplete - giving up”) in new stack"

It calls to nowhere. I also tried other variable names and adding DYNROUTE_ before the variable in the custom destinations. Any ideas?

Is there a way to debug and view the variable? I do not see them in the console (astersik - rvvvvvvv)

Looking at the full log when you make the call will show you what the dynroute is set to. Reports > Asterisk Logfiles

From there you can see what’s wrong.

1 Like

Thanks for the tip! After debugging I found the problem. Works perfectly now!

1 Like

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