Build an SMS Microservice using Python, Twilio and Redis Pub/Sub

Build an SMS Microservice using Python, Twilio and Redis Pub/Sub

Learn how to build a small microservice that communicates through a Redis pub/sub queue to send SMS. Build an SMS Microservice using Python, Twilio and Redis Pub/Sub. We are going to build a simple example of two Python services communicating using Redis Pub/Sub.

Build an SMS Microservice using Python, Twilio and Redis Pub/Sub

A few weeks ago I needed to build a solution to send alert messages to clients of my company. The core service had access to the database, but this service had many responsibilities already and adding a new feature to send a large number of messages could overload it. So I decided to use a different approach: the core service gets the users that should receive the message from the database and builds the message content, but then sends everything to a separate service that actually sends the messages.

This new service that sends SMS messages could be used for many other applications: an alert service to notify clients of promotions, or maybe a reminder service of scheduled appointments. Since it is completely generic, it is easy to reuse it.

For this tutorial we are going to build a simple example of two Python services communicating using  Redis Pub/Sub. The main service is going to send SMS messages using  Twilio Programmable SMS. We will then build a second application that sends an SMS through it.

Tutorial Requirements

To follow this tutorial you need the following components:

  • Python 3.7 or newer. If your operating system does not provide a Python interpreter, you can go to  python.org to download an installer.
  • Redis, an open source, in-memory, NoSQL data store that we are going to use to store de messages.
  • A smartphone with an active phone number and WhatsApp installed.
  • A Twilio account. If you are new to Twilio  create a free account now. If you use  this link to open your account you will receive $10 in credit once you upgrade it.

code microservice

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Static Code Analysis: What It Is? How to Use It?

Static code analysis is a method of debugging by examining source code before a program is run. It's done by analyzing a set of code against a set (or multiple sets) of coding rules. Static code analysis and static analysis are often used interchangeably, along with source code analysis.

How to Find the Stinky Parts of Your Code (Part II)

There are more code smells. Let’s keep changing the aromas. We see several symptoms and situations that make us doubt the quality of our development. Let's look at some possible solutions.

Testing Microservices Applications

In this article, look at different ways to test microservices and how you can have a suitable testing strategy to begin with.

Microservices and Data Management - DZone Microservices

This article describes the nature of microservices applications, contrasts them with monolithic apps, and talk about microservices in data management.

Microservices and Data Management - DZone Microservices

This article describes the nature of microservices applications, contrasts them with monolithic apps, and talk about microservices in data management.