https://github.com/estvita/AsterX
Tested with Asterisk v. 16, 18, 20 (FreePBX) and Yeastar S50
This script allows sending call history and recording files from Asterisk (FreePBX) to Bitrix24.
- Incoming webhook with permissions: crm, user, telephony. Integrations > Rest API > Other > Incoming Webhook.
- Outgoing webhook for the ONEXTERNALCALLSTART, ONEXTERNALCALLBACKSTART events. In the "URL of your handler" field, enter the address http://X.X.X.X:8000/asterx
- Redis Stack
- or SQLite
is used for temporary storage of call information.
cd /opt
git clone https://github.com/estvita/asterx.git
cd asterx
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp examples/config.ini config.ini
nano config.ini
Fill in the Data in config.ini
[app]
- [debug] - Debug mode (True/False)
- [port] - Flask app port: 8000
- [engine] - ami_redis (default), ami_sql or ari to connect asterisk
- [logging] - 0 - disable, 1 - bitrix, 2 - AMI, 3 - full (1+2)
[bitrix] parameters:
- [url] - Address of the incoming webhook.
- [token] - Issued by Bitrix when creating an outgoing webhook.
- [crm_create] - Whether to create a CRM entity or not (1/0).
- [show_card] - 0 - not show, 1 - on call, 2 - on answer
- [default_user_id] - Lost incoming calls are registered to this user (default 1).
[asterisk] parameters:
- [ws_type] - wss/ws - required for connecting to ARI.
- [host] - PBX address (default "localhost").
- [port] - AMI/ARI port.
- [username] - AMI/ARI username.
- [secret] - AMI/ARI password.
- [records_protocol] sftp, http or local
- [key_filepath] - ssh key pach for sftp
- [records_uri] - URL for call recordings with HTTP Basic Auth (https://example.com/monitor/). Example Apache config: [monitor.conf]
- [record_user] - Basic Auth login or ssh user (for sftp)
- [record_pass] - Basic Auth password.
- [internal_contexts] - List of internal (outgoing) call contexts. Default: "from-internal".
- [external_contexts] - List of inbound call contexts. Default: "from-pstn".
cd /opt/bitrix-asterisk
source .venv/bin/activate
+ ARI/AMI: python main.py
+ Event Handler: gunicorn --bind 0.0.0.0:8000 wsgi:app
+ Yeastar API: python yeastar/app.py
Example systemd configuration for automatic startup:
cp /opt/bitrix-asterisk/examples/asterx.service /etc/systemd/system/asterx.service
systemctl enable asterx.service
systemctl start asterx.service