Asterisk connector for Asterisk Calls Odoo application.
Project description
Contents
Introduction
Asterisk Calls Agent is a middleware software used as a bridge between Odoo and Asterisk IP-PBX.
Using Asterisk Calls client makes Odoo a phone applications platform because all development is done on Odoo level so every Odoo developer can quickly and easily integrate Asterisk features with any Odoo module.
The Agent architecture is a callback based where every callback is an Odoo method.
In many cases the Agent will just work as is without any modification like it works in Asterisk Calls application.
Dependencies
Asterisk Calls Agent is based on Nameko - a wonderful microservice framework for Python.
Asterisk Calls Agent is very small because Odoo related operations come from nameko-odoo library and Asterisk related operations come from nameko-ami library.
Though Asterisk Calls Agent was developed as a base for commercial module Asterisk Calls it was decided to make the Agent open and free under LGPL license so that all the Odoo world can benefit from it.
Installation
Currently before installing this package your should manually installed the required dependencies:
pip3 install -r requirements.txt
After that you can install it from PyPi:
pip3 install asterisk-calls-agent
Configuration
Agent
Nameko style config is used. See config.yml for a default config.
#TODO: Describe configuration options here.
Asterisk
See Asterisk Calls module documentation on preparing Asterisk for the Agent.
Running Asterisk Calls Agent
You can start the Agent manually from any place like this:
nameko run --config=config.yml asterisk_calls_client
You can also create a systemd service file asterisk_calls_agent.service and install it for starting the Agent at boot (adjust it for your environment).
[Unit] Description=Asterisk Calls Odoo connector After=network.target [Service] Environment="ASTERISK_SYSTEM_NAME=asterisk" User=root ExecStart=/usr/local/bin/nameko run --config=/etc/asterisk_calls_agent.yml asterisk_calls_agent Restart=always RemainAfterExit=no StandardOutput=syslog StandardError=syslog SyslogIdentifier=ASTERISK_CALLS_AGENT [Install] WantedBy=multi-user.target
And activate it:
systemctl daemon-reload
systemctl enable asterisk_calls_agent
systemctl start asterisk_calls_agent
systemctl status asterisk_calls_agent
Support & Contributing
Feel free to create new tickets on issues and ideas.
Development
As was said in the very beginning development is done on Odoo layer.
The Agent will forward to Odoo specified AMI messages.
In order to know which AMI messages to forward your should define your EVENT_MAP in config file.
Let’s imagine that we want to collect call details records. In this case you need to map Cdr event to Odoo’s model and method which will receive it. Add the following section to config.yml:
EVENT_MAP: - name: Cdr type: AMI model: asterisk_calls.call method: create_cdr
Now in Odoo application named asterisk_calls (just an example) create a method create_cdr with the following contents:
class Call(models.Model): _name = 'asterisk_calls.call' _description = 'Call Log' src = fields.Char() dst = fields.Char() channel = fields.Char() # The rest fields are ommited... @api.model def create_cdr(self, event): get = event['headers'].get data = { 'accountcode': get('AccountCode'), 'src': get('Source'), 'dst': get('Destination'), 'dcontext': get('DestinationContext'), 'clid': get('CallerID'), 'channel': get('Channel'), 'dstchannel': get('DestinationChannel'), 'lastapp': get('LastApplication'), 'lastdata': get('LastData'), 'started': get('StartTime') or False, 'answered': get('AnswerTime') or False, 'ended': get('EndTime') or False, 'duration': get('Duration'), 'billsec': get('BillableSeconds'), 'disposition': get('Disposition'), 'amaflags': get('AMAFlags'), 'uniqueid': get('UniqueID') or get('Uniqueid'), 'linkedid': get('Linkedid'), 'userfield': get('UserField'), 'system_name': get('SystemName'), } self.create(data) return True
That’s it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size asterisk-calls-agent-1.8.tar.gz (19.5 kB) | File type Source | Python version None | Upload date | Hashes View |