Programmatic adjustment of Outbound Route Position

(Saloom) #1

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?


(David55) #2

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.

(Saloom) #3

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

(David55) #4

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.

(Itzik) #5

OP asked about outbound routes in FreePBX…

In the future, it should be doable via GraphQL:

Do NOT edit extensions.conf

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

fwconsole reload

(David55) #6

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.

(Lorne Gaetz) #7

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.

(Saloom) #8

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.