Programmatic adjustment of Outbound Route Position

We have set up a few Outbound Routes, some of which are used for failover scenarios. Whenever needed, we change the relative position of the route entries through the web interface. Is there a way to accomplish this adjustment by using AMI, or any other API-based technique?

Thanks

AMI wouldn’t be an appropriate way of doing this as, routes, and their orders are FreePBX constructs, so will be regenerated into the dialplan when FreePBX restarts. I don’t know if there is a FreePBX API for this.

Hello David, thanks for the reply. Is this information encoded in extensions.conf? If yes, can I use AMI to alter this file instead?

Yes, but you would be manipulating implementation details which are likely to get re-instated without warning. You would need to modify information that is covered by the Do not edit this file warning, albeit you are only manipulating the memory copy.

It is also possible that this is actually done by AstDB entries. My key point is that there is no such thing as route, let alone an order for routes, in Asterisk, so you are playing with code generated by FreePBX.

1 Like

OP asked about outbound routes in FreePBX…

In the future, it should be doable via GraphQL: Sangoma Documentation

Do NOT edit extensions.conf

If you want, you can modify the sequence table asterisk.outbound_route_sequence and then reload FreePBX

fwconsole reload
1 Like

But he also asked about using AMI and editing the dialplan directly. These are only easy to do when you are manipulating constructs that are native to Asterisk. I was pointing out that the constructs weren’t native to Asterisk, so you have to take into account how FreePBX implements them.

I think people sometimes think that the GUI is just a thin veneer and all the abstractions actually exist in Asterisk.

1 Like

I suspect this can be done by altering the sql directly:

MariaDB [asterisk]> select * from outbound_route_sequence;
+----------+-----+
| route_id | seq |
+----------+-----+
|        1 |   1 |
|        2 |   3 |
|        3 |   2 |
+----------+-----+
3 rows in set (0.00 sec)

Needs testing, I’ve never touched this table before.

Thank you all very much. I also thought that FreePBX was just a GUI for Asterisk. Unfortunately, I have to alter the configuration through a sort of API call and not through the console. I found an unorthodox solution. I cloned the HTTP POST requests that FreePBX is making to achieve the changes I am interested in. I also cloned the login POST requests since it is a prerequisite. I tested it on Postman and it works like a charm.

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