ettoreleandrotognoli / python-ami

Python AMI Client
BSD 3-Clause "New" or "Revised" License
107 stars 66 forks source link

Call extension to extension #11

Closed iruindegi closed 7 years ago

iruindegi commented 7 years ago

Hi,

First, thank you for this awesome library ;)

I'm developing a small app witch is working very well with this lib. But I have a problem when I need to Originate a call from a extension (6426) to another extension (6422) for example, both of them with a fisical terminal. If I use this code:

from asterisk.ami import AMIClient
from asterisk.ami import SimpleAction

client =AMIClient(address = 'SERVERIP', port=PORTNUMBER)
client.login(username = 'USER', secret = 'PASSWD')

action = SimpleAction(
    'Originate',
    Channel='SIP/4123216082108749',
    Exten='6422',
    Priority=1,
    Context='default',
    CallerID='python',
)
future = client.send_action(action)
response = future.response

print(response)

When I run this code the terminal (channel) start ringing, and if I answer the call is finished with this result:


Response: Success
ActionID: 1
Message: Originate successfully queued

What i need it to make a call from this channel to the another terminal with has the extension 6422. How to achieve that? I installed fop2 (https://www.fop2.com/) I they have implemented this: first original terminal rings and when you hang up it start ringing to the destination. When destinarion terminal hangups, they can start speaking.

Is there any way to do that with yout library?

Thanks in advance

ettoreleandrotognoli commented 7 years ago

Hi! Thanks, I'm happy for someone are using this lib I didn't have the opportunity to test yet, but try this:

action = SimpleAction(
    'Originate',
    Channel='SIP/4123216082108749', # put the correct channel here, I think is SIP/6426
    Exten='6422',
    Priority=1,
    Context='from-internal',
    CallerID='python', # you can change this, is only for show
)

I only have changed the context to "from-internal"

If that won't work report to me again and I will search something to resolve.

iruindegi commented 7 years ago

yes! in my case the context was diferent, but it's working now. Thanks!!