This is a prototype of a call controller using Broadvoice APIs in Python 3.7. There are 2 parts to it.
There's a web service to receive signaling events from Broadvoice (i.e. incoming call, DMTF input, etc). This web service is developed using the Flask framework. The web routes are defined in the app/routes.py file.
To send signaling commands to Broadvoice (i.e transfer call, place call on hold with Moh, start recording, etc), the call.py file builds these requests using Broadvoice's REST APIs. This cli is not integrated with the web service.
To install the required modules, run the following command from a terminal.
pip install -r requirements.txt
or alternatively pip3 install -r requirements.txt
This will install the following:
- virtualenv
pip install virtualenv
orpip3 install virtualenv
- ngrok
npm install ngrok
- Flask
pip install Flask
orpip3 install Flask
- requests
pip install requests
orpip3 install requests
If you don't already have direnv installed, run the following command:
pip install direnv
or pip3 install direnv
Modify your shell profile (i.e. ~/.bash_profile) by adding the following:
eval "$(direnv hook bash)"
Restart your shell so the environment variables defined in .envrc are loaded when nagivating to this project from a terminal window.
Flask runs in a Python3 virtual environment. To create this virtual environment, run the following command:
python3 -m venv ve
This create a virtual environment named ve
. You can change this name to your liking.
To expose the flask web service externally, run ngrok passing the default port number used by the Flask web service. This would be 5000
from the URL http://127.0.0.1:5000
. If the Flask web service uses a different port number, you'll need it instead of 5000
.
ngrok/bin/ngrok http 5000
Before starting the web service, activate the virtual environment (created in the previous section) by running the following command:
source ve/bin/activate
Next, modify the file, .envrc, to specify the ngrok URL in the environment variable NGROK_CALLBACK
. Then run the following command:
direnv allow
To start the Flask web service, open a terminal window, navigate to this folder, and run the following command:
flask run
For Broadvoice to send signaling events to your Flask web service, it needs the URL to the Flask web service running locally exposed externally by ngrok. Use the following steps to configure this callback URL. The callback URL is called by Broadvoice when a signaling event occurs.
- Sign-in to the Broadvoice dashboard.
- Navigate to Settings -> Destinations -> Call Flow.
- click Edit on the Remote Call Flow entry.
- Modify the Response URL with the ngrok URL (see Configure Ngrok section) as shown in the below screenshot.
- https://github.com/xbpio/cpaas-docs/wiki
- http://developer.voipment.com/
- https://github.com/xbpio/cpaas-docs/wiki/REST-API
This project is under development