Phone line forwarding using api

Please, how can I redirect a specific phone extension to another extension or external number via the ami interface? There is a button on cisco phones that, when pressed, can redirect the phone to another phone, but I would need to do this via some ami or api interface. I am a beginner with an asterisk and its ami, api interface. Thank you

AMI cannot redirect extensions, other than by adding lines to the dial plan, and I don’t think that is what you meant. It manipulates channels, which are dynamic, not extensions, which are static.

The sort of redirection you are talking is something that would generally be implemented in dialplan, rather than external scripting.

Simulating what I think the Cisco will do would involve storing a record in AstDB keyed by the original extension number (which I assume is the same as the caller ID) and containing redirected one, and having the oirignal extension dialplan read that database record, and if the target extension was different, use Goto to get to the new extension.

To redirect an active channel to an extension from AMI, use the redirect action on the channel, giving the context, and extension of the destination, and 1 as the priority.

Thank you, I redirected the call as follows. I have two phones. The first phone has the number 100 and the second phone has the number 101. On the first phone, I will divert all calls to the phone 101, so when someone calls 100, the phone 101 will ring. This is a complete forwarding of both internal and external calls. On the phone 100, the call divert button 101 can be canceled. I need an api to remotely redirect phone 100. Thank you, maybe I explained it better.

Asterisk is a toolkit. You will have to write your own implementation of that API. The implementation will be dependent on your current dialplan, so cannot be provided in isolation.

In particular, call forwarding is not an intrinsic capability of Asterisk; it is always constructed from lower level constructs, such as those in my first reply.

Asterisk is not a PABX, but rather a toolkit for constructing PABXes.

It is also possible that the Cisco phone is implementing the call redirection within the phone itself, in which case the PABX has no access to the process; the phone simply responds with status 302 and the new directory number, when called.

you can write 2 variables on the ASTDB as described before, directly from AMI using a Local channel
var1 redirection value on or off
var2 number where the calls will be redirected

and then add a conditional statement to check if var1 is active or not

1 Like

Thank you could you please give an example. I’m trying to make scripts in python that would switch calls. Using https://github.com/ettoreleandrotognoli/python-ami/

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