Code, Tutorials and Hacks
At Signal 2020, Twilio announced Event Streams - an API that allows developers to subscribe to a stream of interactions from Twilio in the form of well-defined Events. Since then, the team has been hard at work adding more and more event types from within the Twilio platform. Not only that, but Event Streams went into Public Beta in April 2021, adding a Webhook sink type on top of the AWS Kinesis sink type.
The availability of Event Streams, and the many event types which can be streamed to your application, has opened up myriad opportunities to use Event data from Twilio in new and interesting ways.
In this guide, we will create a Slack App which will post to a channel in Slack every time one of our Flex / TaskRouter workers changes their selected Activity status in Flex.
To do this, we will be doing the following:
- Using …
As security threats continue to grow and their impacts become ever-more significant, Two-factor Authentication (2FA) is progressively becoming a de facto security standard. As an extra layer of security to the traditional username/email and password combination normally provided by the user(s) of an application, Two-factor authentication works and can be implemented by:
- Generating and sending a numeric code to the user's mobile device either via SMS, email, or phone call. This is popularly called One-Time Password (OTP) as it is a short-live password that can only be used once during authentication.
- Using an authenticator app to provide a constantly rotating set of codes that can be used for authentication when needed.
- Using push authentication where a user responds to a device push notification to either approve or reject an in-application event.
In this article, I will show you how to generate an OTP and send it to the user via …
Whether you are just starting to build with Twilio Programmable Video or are looking to optimize your application in production, access to the inner workings of your video application is essential to iterate fast and verify code changes to lead to the outcome you are looking for. You could dive into the Room object through the browser console, but the values are not updated in real-time, and it often takes many clicks to find the value you want. Furthermore, some of the metrics you need for optimizing your application aren’t easily consumable. For example, although you can get the total bytes sent for a given track after some number of clicks, what you probably want is the bitrate. And you probably want to see how it changes in real-time. As you go through the various stages of development, this process becomes cumbersome and the time it takes to access the …
Java programmers can benefit from using servlets because they provide an opportunity to understand low-level concepts in Java. Servlets are also great for building interactive web applications and dynamic web pages because they extend apps hosted by web servers. They handle HTTP requests between a browser and any client, database, or application on the HTTP server.
However, building a local servlet is just the first step. Taking the servlet a step further to communicate with a temporary public domain can allow developers to use webhooks, share a working demo of the project, and more.
In this article, you will learn how to build and run a servlet to host your Java application and expose it publicly to the web.
Ngrok is a great tool because it allows you to create a temporary public domain that redirects HTTP requests …
>>> import os >>> user = os.environ['USER'] >>> user 'miguel'
>>> database_url = os.environ['DATABASE_URL'] Traceback (most recent call l …
Setting up a new project to hack together an idea shouldn't be a problem, especially with the help of the Spark framework. Not only does this lightweight framework allow developers to be more productive with minimal boilerplate, but explore REST APIs at the same time.
In this article, you will learn how to navigate a Java IDE to set up and build a Java Spark application.
- Java Development Kit (JDK) version 8 or newer.
- IntelliJ IDEA for convenient and fast Java project development work. The community edition is sufficient for this tutorial.
Start a new Java project in IntelliJ
Open IntelliJ Idea and click on Create New Project.
Choose Gradle on the left hand side a …
Many applications verify and authorize their users by sending a numeric code, called a One-Time Passcode (OTP), to the user’s phone number via either a voice call or a text message.
To get started with this tutorial, you’ll need the following:
- Node.js installed on your machine, along with a package manager like
- A free Twilio account (sign up with this link and get $10 in free credit when you upgrade your account)
- A phone where you can receive text messages
Scaffold your backend
In your terminal or command prompt window, navigate to your main projects or development folder. From there, run the following commands to create a new project folder, …
Systems and Infrastructures are constantly monitored, and monitoring teams need to dispatch technicians to fix issues as fast as possible when an incident is raised. Using the Twilio API you already can call a single number to reach a technician and deliver a message, or call several numbers and deliver the message to the first person who answers. In this article we introduce an escalation loop: define several people to be called in case of an incident and call them in order, one after the other, until one of them accepts the call.
For this to happen, we created a reusable set of Twilio Functions that can be triggered by a simple call to a REST API. The code for this solution is available on Github and can be easily deployed on your Twilio project.
Before you can build the escalation and notification loop, you'll need to register or …
Do you forget to send birthday wishes to your friends and loved ones? I do, and it usually results in being scolded by my fiancée! I’ve often wished for a software program that could send birthday wishes on my behalf.
In this tutorial, we will create this exact end-to-end system. We will use Twilio's What’sApp API for sending the messages, the Flask web framework for the web server, and we will run messaging jobs periodically using APScheduler. We’ll also deploy the Flask application to AWS so it can be deployed resiliently and at scale.
The complete code for this tutorial is available in this Github repository.
Figuring out code ownership at a large company can be challenging. And identifying code owners during code related incidents is hard – with an element of stress to boot. The Product Security team at Twilio set out to solve our code ownership challenges in a way that we think can help you as well.
Today, we’re proud to release two things that go along way towards solving the problem:
- about.yaml - a new code ownership file specification that has all the information you need to trace any code’s current owner across your company
- Gordon - a Github app service to monitor repositories for keeping about.yaml files up-to-date.
Why do we need this?
More times than we’d like to admit, we found ourselves in a situation where we find a bug or vulnerability in a piece of code, do a
git blame to see who last touched that code, and find …