This is a example of how you can build a telephony switch where you can configure who gets incoming calls via SMS
- A 46elks account
- 2 virtual numbers from 46elks
- One that your customers will call
- One used for controlling the system (could technically be the same as the first one, but that would cause incoming messages from your customers to be parsed as commands)
- Copy config.toml.sample to config.toml
- Edit the config to correspond with your system setup
- The
host
value can be left as is - The
port
value needs to be unlocked for incoming traffic in your firewall and be accessable from the internet base_url
needs to be set to the URL where this server can be reached on. For example yourdomain.com.- The
static_dir
parameter should be set to a absolute path instead of a relative one
- The
The virtual numbers can be configure on the 46elks.com dashboard or directly via the API. See our documentation for more details https://46elks.com/docs/configure-number
Should be set to f"{base_url}:{port}/incoming_calls"
Ex if your base_url is http://yourdomain.com and the port is 8080
voice_start -> http://yourdomain.com:8080/incoming_calls
Should be set to f"{base_url}:{port}/incoming_sms"
Ex if your base_url is http://yourdomain.com and the port is 8080
sms_url -> http://yourdomain.com:8080/incoming_sms
It is a good idea to install python dependencies in a virtualenv. This isolates the packages from the rest of your system packages.
pip3 install virtualenv
virtualenv env
source env/bin/activate
pip intall -r requirements.txt
For production environments the server should be ran using a more stable web server than the built in dev server, for example waitress or gunicorn. But for demo and development purpses the dev server works fine.
The server can be started with:
python3 sms-switch.py
Copy users.json.sample
to users.json
and add the users that are allowed to controll the server
Commands can be sent in text messages to the controll number
- set [name] - sets [name] as the active user that will receive calls
- who - Replies with the name of the active user
- disable - removes the active user, disabling call forwards