Build a Live Traffic WhatsApp Chatbot with Python, Flask, Folium and Twilio
Like most people I am endlessly frustrated by sitting in slow-moving traffic and I often wonder if I just got unlucky or is it always like this? In this tutorial I’m going to show you how to answer that question by building a basic chatbot for WhatsApp using the Twilio API for WhatsApp and the Flask framework for Python.
The chatbot will allow users to share their current location and get back a live traffic report and a link to an interactive map. Here’s an example showing how it works:
To follow this tutorial you will need the following:
Build a Survey App With Python, Twilio, and Airtable
Airtable is like a cool big-budget superhero crossover between a spreadsheet and a database.
The survey app we are going to build will gather NPS, which stands for Net Promoter Score, a metric used to measure customer experience. However, you can customize the survey for purposes specific to your needs. Try it out by texting your favorite emoji to the number below.
We’ll go through this step-by-step, and we will do it all in a single file. If you would like to download the complete project you can find it in this GitHub repository: https://github.com/Eclairemoy/nps-survey
Building the Project
Voice and SMS One-Time Passwords with Python and Twilio
One-time passwords (OTPs) contain numeric or alphanumeric codes that are used to provide an extra layer of security for your applications, by ensuring that a user is authenticated for a particular transaction or a login session. In this tutorial, we’ll be building a simple Flask application that generates and validates OTPs that are delivered to users via Voice or SMS channels using Twilio.
To follow along, you’ll need the following:
- A free Twilio Account. If you use this link to register, you will receive $10 credit when you upgrade to a paid account.
- Python 3.6 or newer.
- A phone line that can receive voice calls and/or SMS.
Creating a Python environment
Let’s create a directory where our project will reside. From the terminal, run the following command:
$ mkdir twilio_otp
cdinto the project directory and run the following command to create a virtual environment.
Send Dynamic Emails with Python and Twilio SendGrid
Email is a critical part of any business communication strategy, both internally and externally. Today the need to have dynamic, content-driven, responsive email campaigns is critical. Twilio SendGrid allows organizations to deliver on this need with a highly performant and customizable CRM that works well in both the GUI and programmatically via API.
In this tutorial, we’ll set up a free SendGrid account and, using Python, send ourselves both simple text/html emails as well as high-res, dynamic content. We’ll also retrieve sending data like the number of emails sent, how many were opened or clicked, if any bounced, etc.
By the end of the tutorial you’ll be able to:
- Set up a free SendGrid account and API key for interacting with the service
- Set up a Python application that calls the SendGrid Web API v3, sends emails to different lists, and retrieves statistics about those sends
- Start working with …
Construindo um Twilio Webhook seguro com Python e FastAPI
Alguns dias atrás, eu estava procurando por um Framework Web Python para construir uma aplicação de chat que fosse assíncrona e que tivesse alta performance. Como eu sou bem familiarizada com Flask, não quis gastar tempo aprendendo algo muito diferente.
Foi então que eu encontrei o FastAPI: um framework web moderno para construir APIs com Python 3.6+, baseado no Starlette e inspirado no Flask. Este framework utiliza o padrão das type hints, já traz validações e serialização, além de usar o padrão aberto para APIs, OpenAPI. Foi uma escolha perfeita porque este framework não somente suporta requisições assíncronas como também geração automática de documentação. Você pode encontrar outros recursos incríveis do FastAPI aqui.
Nesse tutorial, nós vamos construir um webhook Twilio usando esse framework fantástico. Para entender na prática como o FastAPI funciona e como podemos construir aplicações com ele, vamos implementar um webhook seguro …
Build a COVID-19 Bot with Python and Twilio Autopilot
Twilio Autopilot makes it easy to build conversational bots that provide information to users in a highly engaging and intuitive format. A single Autopilot bot can be deployed on several channels including SMS, Voice, WhatsApp, Slack, Alexa and more.
In this tutorial we are going to build a bot that provides COVID-19 stats for all countries using a purely conversational style. We will train the bot with example sentences to help it extract meaning from the freeform text entered by the user. Once you learn how this specific bot works, you will be able to adapt it to other data sources.
The aspects that make this bot interesting that I’d like you to notice are:
- The user makes requests in an informal and conversational tone. Autopilot makes it very easy to “teach” the bot how people ask questions using freeform language, and how to extract the actual information embedded in …
Secure your video conference with one-time passcodes
As we dutifully practice social distancing, live video conferencing is increasingly popular. From company meetings to yoga classes and magic shows, traditional in person events are going virtual. But while technology connects us, it also comes with privacy and security risks.
This post will show you how to add one-time passcode authentication on top of your Twilio Video application to ensure that only registered users are able to access the conference.
While passwords may help protect against war dialing, they don't guarantee that the people joining the video conference should be allowed to participate. A lot of people are still widely sharing Zoom meeting IDs and passwords.
One-time passcode authentication is useful for gating:
- Paid content like workout classes, political fundraisers, or live dating shows.
- Sensitive content with an access control list (ACL)
This tutorial will walk you through adding Twilio Verify SMS verification to …
Handle Twilio Debugger Events with Python and Flask
Twilio offers a wide range of APIs. One Twilio account can run many applications, and perhaps your team develops and maintains a specific range of them. To best debug your applications when (and not if) there are errors, it would be nice to filter through debugger events and only get the notifications that you need to see.
In this post, I’ll show you how to leverage Twilio’s Debugger Alert Triggers to receive, process and store the error events from your selected Twilio application. That is, you’ll be able to write an application that listens to events from the Twilio Debugger and writes relevant content about them into a comma separated values (CSV) file that you maintain on your machine. In a more advanced project, you could write this into a cloud database instead. The idea is the same.
We will be using Python, so I’ll assume …
Testing a Twilio Interactive Voice Response (IVR) System With Python and pytest
In a previous tutorial you learned how to build an IVR system with Python, Django and Twilio. In that project you created an IVR system that provides users with information about movie show times over the phone.
In this article you are going to add automated tests for the IVR system using Pytest.
Why You Should Test Your System
Maintaining good and comprehensive tests is crucial for your project's success. First, as a developer, writing tests gives you an opportunity to experience what it's like to be a customer of your own system. Whether you are developing an API, a website, a dashboard or an IVR system, writing tests is like using your own system. If there is something wrong, or something that can be improved, you are going to notice it when you try to test it.
Good tests are tests you can trust. If once all the …
The efforts to limit the spread of COVID-19 around the world have forced a large number of people to work from home and this has naturally created a surge in interest for communication and collaboration tools.
If you are worried that this is going to be a long, difficult and obscure tutorial …