Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Asterisk AMI Plugin

Questions and comments specific to a particular plugin should go here.
Post Reply
TheOgre
Posts: 7
Joined: Thu Oct 06, 2011 1:52 am

Asterisk AMI Plugin

Post 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
Attachments
__init__.py
(6.95 KiB) Downloaded 204 times
TheOgre
Posts: 7
Joined: Thu Oct 06, 2011 1:52 am

Re: Asterisk AMI Plugin

Post 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 2150 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'])
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Asterisk AMI Plugin

Post 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
TheOgre
Posts: 7
Joined: Thu Oct 06, 2011 1:52 am

Re: Asterisk AMI Plugin

Post 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..
Post Reply