1. Create a 46elks account.
  2. A virtual number
    Because you’re here you’ve received a phone number for free on your account that you can use freely for two years. You can see your number here.
    Can't see a number? Ask an elk and we'll help!
  3. A live server to run your code on. Text your first name to +46766865445 to get an account on our live server.
  4. SMS account

Be patient with yourself and others. We'll help each other out!

What we're doing today

  1. Login to the production server.
    Change username to your own username on the server.
    Use the password from the SMS

    
                
  2. mkdir switchboard
  3. cd switchboard
  4. Set up virtualenv
    $ python3 -m venv venv
    $ . venv/bin/activate
    $ pip install requests
    $ pip install Flask
    $ pip install Flask-APScheduler
  5. vim app.py
  6. Import Flask and name it

    
                
  7. Define our url and change this your_port_number to your port number

    
                
  8. Set up new route

    
                
  9. ESC + :wq
    (How to exit in Vim. Yes, it's possible)

  10. Run your Flask app.
    Replace your_port_num with your own port number

    
                

    To stop Flask run CTRL+C

  11. Visit your Flask app
    Replace your_port_num with your own port number

    
                
  12. The set up works, now let’s code the switchboard ☎️

  1. In your app.py import json and flask request

    
                
  2. - The API expects a json with details about what to do with the incoming call
    Let’s check out the documentation to see what that looks like…
    Docs → PHONE CALLS → connect

  3. {"connect": "+46700000046"}
  4. Change the route to accept incoming calls

    
                
  5. Change the route to accept incoming calls

    
                
  6. We need to connect the call to one of the users in our users.txt

    
                
  7. Then your code will look like this in full

    
                
  8. Log in to your 46elks account.
  9. Click numbers.

    You should have gotten a telephone number automatically when creating your 46elks account through the registration link on this page.

  10. Click edit next to your virtual number.
  11. Click edit next to voice_start to edit the URL, and set it to.
    
                

    Should look something like this in your dashboard

Because of limitations by operators, you can’t call yourself from your own phone number.. So let’s set “from” to your virtual phone number for testing purposes.
You can also call your workshop neighbour to get the full experience of seeing the phone number of the person who’s calling.

    How to switch "who's it"

  1. At the top add

    
                
  2. In your route add

    
                
  3. Now define user and make sure the calls just not go to the same person each time

    
                
  4. Then your code will look like this in full now

    
                

To let your switchboard know that you are available you need to opt-in.
To do this you simply send a SMS to your virtual number with the text "login" and "logout" depending on your choice. It works with both Upper- or lowercase.

SMS conversation showing how to log in and log out

Test your app

Ask someone (perhaps the person next to you) to call your virtual number and the call should be connected to your regular phone.

What now?

This switchboard can be extended with other functionalities based on your needs.
Here are a couple of suggestions on how you can adjust your new switchboard:

The full code is here in case something happened to yours on the way