A running asterisk daemon with a configured Asterisk Manager Interface (AMI) is necessary. In manager.config its required to enable at least: read = system,call,user,cdr and write = system,call,orginate In misc/asterisk some configuration files from the authors asterisk are available to learn from.



The plugin needs the username and password of the AMI and a IP and port address if asterisk does not run on localhost.

    class_name = Asterisk
    class_path = plugins.asterisk
    username = admin
    password = secret
    host = # default
    port = 5038 # default



Its possible to specify the ast_dev attribute to an bool item in items.conf. The argument could be a number or string and corrospond to thhe asterisk device configuration. E.g. 2222 for the following device in asterisk sip.conf:



The mailbox number of this phone. It will be set to the number of new messages in this mailbox.


Specify the database entry which will be updated at an item change.

In items.conf:

        type = bool
        ast_dev = 2222
        ast_db = active/office
            type = num
            ast_box = 22

Calling the ‘2222’ from sip client or making a call from it, office.fon will be set to True. After finishing the call, it will be set to False.


It is possible to specify the ast_userevent keyword to every logic in logic.conf.

    ast_userevent = Call

    ast_userevent = Action

In the asterisk extensions.conf exten => _X.,n,UserEvent(Call,Source: ${CALLERID(num)},Value: ${CALLERID(name)}) would trigger ‘logic1’ every time, this UserEvent is sent. A specified destination for the logic will be triggered e.g. exten => _X.,n,UserEvent(Call,Source: ${CALLERID(num)},Destination: Office,Value: ${CALLERID(name)})


call(source, dest, context, callerid=None)'SIP/200', '240', 'door') would initate a call from the SIP extention ‘200’ to the extention ‘240’ with the ‘door’ context. Optional a callerid for the call is usable.

db_write(key, value)

sh.ast.db_write(‘dnd/office’, 1) would set the asterisk db entry ‘dnd/office’ to 1.


dnd = sh.ast.db_read(‘dnd/office’) would set ‘dnd’ to the value of the asterisk db entry ‘dnd/office’.

mailbox_count(mailbox, context=’default’)

mbc = sh.ast.mailbox_count(‘2222’) would set ‘mbc’ to a tuple (old_messages, new_messages).


sh.ast.hangup('30') would close all connections from or to the device ‘30’.