Skip to main content

Track channels through Asterisk Management Interface (AMI)

Project description

Cacofonisk

Cacofonisk is a framework that connects to the Asterisk PBX, listens to events on the Asterisk Management Interface (AMI) and tracks the status of calls currently in progress in Asterisk.

Cacofonisk takes a stream of AMI events as input and uses these to keep track of the channels currently active in Asterisk and how they are related. When something interesting happens to one of the channels, it will call a method on a call state Reporter with interesting information about the call, like who is in the call, and a unique identifier.

This data can then be used to send webhooks regarding a call, to notify a person who is being called, or to log calls being performed.

Status

This product is actively being developed and used at VoIPGRID.

Usage

Requirements

  • Python >= 3.4
  • Panoramisk 1.x
  • Asterisk >= 12

Installation

Cacofonisk is available on Pypi so you can easily install it with pip:

$ pip install cacofonisk

To install the dependencies from source:

$ python3 setup.py install

Running

To run Cacofonisk, you will need two things: a Runner and a Reporter.

A Runner is a class which is responsible for passing AMI events to the Cacofonisk. Two runners are included: an AmiRunner (which connects to the Asterisk Management Interface) and a FileRunner (which imports AMI events from a JSON file).

A Reporter is a class which takes the interesting data from Cacofonisk and does awesome things with it. You can find various Reporters in the examples folder.

To create your own reporter, you can extend the BaseReporter class and implement your own event handlers, like so:

from cacofonisk import AmiRunner, BaseReporter


class ReportAllTheThings(BaseReporter):

    def on_b_dial(self, caller, targets):
        target_channels = [target.name for target in targets]
        caller_number = caller.caller_id.num
        print("{} is now calling {}".format(
            caller_number, ', '.join(target_channels),
        ))

    def on_up(self, caller, target):
        target_number = target.caller_id.num
        caller_number = caller.caller_id.num
        print("{} is now in conversation with {}".format(caller_number, target_number))

    def on_hangup(self, caller, reason):
        caller_number = caller.caller_id.num
        print("{} is no longer calling (reason: {})".format(caller_number, reason))


reporter = ReportAllTheThings()
runner = AmiRunner(['tcp://username:password@127.0.0.1:5038'], reporter)
runner.run()

This reporter can then be passed to a Runner of your choice to process AMI events.

For more information about the parameters of the reporter, please see the docs in BaseReporter.

You can also listen for UserEvents using the on_user_event function. This can be used to pass additional data from Asterisk to your Cacofonisk application.

Running the tests

To run the test suite:

$ python3 -m unittest

Contributing

See the CONTRIBUTING.md file on how to contribute to this project.

Contributors

See the CONTRIBUTORS.md file for a list of contributors to the project.

Roadmap

Changelog

The changelog can be found in the CHANGELOG.md file.

In progress

No features are currently in progress.

Future

No features are currently scheduled. Have great ideas? Please don't hesitate to share them!

Get in touch with a developer

If you want to report an issue see the CONTRIBUTING.md file for more info.

We will be happy to answer your other questions at opensource@wearespindle.com.

License

Cacofonisk is made available under the MIT license. See the LICENSE file for more info.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cacofonisk-0.7.7.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

cacofonisk-0.7.7-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file cacofonisk-0.7.7.tar.gz.

File metadata

  • Download URL: cacofonisk-0.7.7.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.13 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for cacofonisk-0.7.7.tar.gz
Algorithm Hash digest
SHA256 bcca08657c7a4fe4e12439fdebb0c08ab3823adcc2e3ddcca0ccd101158e7684
MD5 fbb04c5d6251d0591103af2dcc7e7b63
BLAKE2b-256 b899983dd1257252c1493dd2dda2fd1385ee0d4df2b8ace132055eec6c547ae9

See more details on using hashes here.

File details

Details for the file cacofonisk-0.7.7-py3-none-any.whl.

File metadata

  • Download URL: cacofonisk-0.7.7-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.13 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for cacofonisk-0.7.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4b51e560e26f441bffcdf6637028ee80ec58fd8c51f98252ee33e7c8776efc6b
MD5 3043557c46b43130433dba3267b33c82
BLAKE2b-256 f37e6f867ebbb329453218b99666f75df41db03acfe1c877dfd363b278835649

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page