Ever had a situation where you wanted to provide a phone number but due to security issues you don’t want to share your personal number but still want to receive SMS? You can use Twilio to get those messages forwarded to an email address!

Today we’re going to explore how to set up a bridge between your email inbox and SMS using Twilio, SendGrid and Python. We’ll be using the FastAPI framework for building the server, Twilio SendGrid to send emails and Twilio Programmable Messaging to accept SMS.

Tutorial requirements

  • Python 3.6 or newer. If your operating system does not provide a Python interpreter, you can go to python.org to download an installer.
  • A free Twilio SendGrid account. Sign up here.
  • A Twilio account. If you are new to Twilio create a free account now!

Setting up the development environment

Before we kick off, let’s create a Python virtual environment to start clean. We’ll be making a folder and a virtualenv inside the folder. We’ll then install the following packages to use with this project:

Follow these steps to setup a virtualenv and install the packages:

$ mkdir twilio-email-sms
$ cd twilio-email-sms
$ python -m venv venv
$ source venv/bin/activate ## For Linux and Mac
$ venv\Scripts\activate ## For Windows
(venv) $ pip install fastapi uvicorn pyngrok httpx python-multipart python-dotenv twilio

#code #tutorials and hacks #python

Build an SMS-to-Email Bridge with Python, FastAPI and Twilio
4.50 GEEK