Page 1 of 1

Asterisk AMI Plugin

Posted: Wed Oct 12, 2011 4:19 am
by TheOgre
Hi All,

Here is my first plugin, I'm new to Eventghost and Python so please be nice. It's quick and dirty, and I'm sure there are better ways to do what I am doing - but it seems to work for the intended purpose.

This plugin connects to an asterisk box via the AMI interface. It generates an eventghost event each time it receives an event from the AMI.

Just as an example, this could be used to perform an action on an incoming call - Like a popup message with the callerid within xbmc.

To enable the AMI interface on your asterisk box, you will need to modify /etc/asterick/manager.conf

Code: Select all

[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0

[eg]
secret = eg
permit=0.0.0.0/0.0.0.0
read = system,call,log,verbose,command,agent,user,originate

v0.1.0 - 2011-10-12 - Initial release
v0.2.0 - 2011-10-12 - Added filtering

Re: Asterisk AMI Plugin

Posted: Wed Oct 12, 2011 11:32 pm
by TheOgre
Ok, so I thought I'd add an example.

This is how you can send the CallerID of an incoming call to XBMC.

I've added 2 plugins to the Configuration tree - Asterisk AMI and XBMC2

I've created a macro with a Python Script, and used the AsteriskAMI.Newstate event to trigger it
config.PNG
config.PNG (13.28 KiB) Viewed 2148 times
The Python script is as follows:

Code: Select all

if type(eg.event.payload) is dict \
    and 'ChannelStateDesc' in eg.event.payload \
    and 'CallerIDNum' in eg.event.payload \
    and eg.event.payload['ChannelStateDesc'] == 'Ring':
        eg.plugins.XBMC2.SendNotification(u'Incoming Call', eg.event.payload['CallerIDNum'])

Re: Asterisk AMI Plugin

Posted: Thu Oct 13, 2011 4:36 am
by krambriw
This looks very nice!

What download sw package do you recommend for asterisk? For Windows or Ubuntu...

I see a great value for this using asterisk and connect to Skype. I found Skype2SIP but your inputs and experience/recommendation would be very much appreciated.

Best regards, Walter

Re: Asterisk AMI Plugin

Posted: Sun Oct 16, 2011 10:42 pm
by TheOgre
your best bet for asterisk is to use one of the pre-built distros. As long as you have a fairly recent pc, you should have no problem running it inside a virtual machine.

In the past I would always use trixbox for any asterisk install, but recently i've been using the freepbx distro with good results.

I haven't used the skype2sip plugin you mentioned, so I can't be much help there..