Source code Github
Create web server on the same server as asterisk. This server can:
- Provide asterisk calls history by http endpoint like start_datetime and end_datetime (mysql,postgresql,sqlite,csv)
- Provide webhooks for asterisk. Allows you to send request to your site, for example, an incoming call that was answered or a missed call. Next, your server saves this to the database and notifies clients (browsers) through any mechanism (websockets, longpolling) that a call has arrived and, for example, by calling a pop-up window and creating a lead or opening a partner's card
- Also provide recordngs although they are available in asterisk ari, just to address the same address. (essentially a duplication)
- Endpoint numbers list
- Endpoint checkup ( getting the status of the service) After launching the service, the documentation with the available endpoints will be at your_ir:8082/docs Simple http base authentication is also enabled, the username and password are taken from the config to protect your data in asterisk.
- Enable the Asterisk HTTP service in /etc/asterisk/http.conf:
[general]
enabled = yes
bindaddr = 0.0.0.0
bindport = 8088
- Configure an ARI user in /etc/asterisk/ari.conf:
[general]
enabled = yes
pretty = yes
allowed_origins = localhost:8088,http://ari.asterisk.org
[asterisk-supersecret]
type = user
read_only = no
password = $6$nqvAB8Bvs1dJ4V$8zCUygFXuXXp8EU3t2M8i.N8iCsY4WRchxe2AYgGOzHAQrmjIPif3DYrvdj5U2CilLLMChtmFyvFa3XHSxBlB/
password_format = crypt
By default, the environment data is read from the .env file. Perhaps the .env.sample file as an example will help you (just rename that). Please set your credentials to it file before work.
On your asterist server. Setup python enviroment. Python version 3.11.0 or more. A best practice among Python developers is to use a project-specific virtual environment. Once you activate that environment, any packages you then install are isolated from other environments, including the global interpreter environment, reducing many complications that can arise from conflicting package versions. You can create non-global environments in VS Code using Venv or Anaconda
python -m venv .venv
python -m pip install -r requirements.txt
Start from root folder backend web server (ASGI) as service
uvicorn main:app --host 127.0.0.1 --port 8082 --log-level debug
or
python3 -m uvicorn main:app --host 127.0.0.1 --port 8082 --log-level debug --workers 2
On your asterist server. Setup docker enviroment.
Start from root folder backend web server (ASGI) as docker service
docker-compose -f docker-compose.yml up