Start a new Twilio Functions project the easy way
If you're building a Twilio project you will inevitably need to run some code in response to an incoming webhook request. One of the easiest ways to do this is with Twilio Functions, our serverless platform for running Node.js. Recently my colleague Dominik released the
twilio-runpackage that makes it easier to develop, test and debug Twilio Functions locally.
I wanted to make it even easier to get started with a Twilio Functions project, so I built a project generator called
Let's take a look at how you can easily start and develop a Twilio Functions project using
There are a few ways you can use
create-twilio-function. The easiest is if you have
npmversion 6 or higher. You can check this out on the command line with:
$ npm --version 6.9.0
If you don't have an up to date version of ...
Send Images and Other Media via WhatsApp Using Node.js
The Twilio API for WhatsApp allows you to not only send text-based messages to WhatsApp numbers but also send and receive media messages. This allows you to send images (JPG, JPEG, PNG), audio files and even PDFs up to 5MB. Let's see how we can do this using Node.js.
First Things First
Before we get started, make sure you have:
- A Twilio account (sign up for free)
- Node.js and a package manager like
- The WhatsApp Sandbox Channel installed (learn how to activate your WhatsApp sandbox)
- Set your Account SID and Auth Token as environment variables
If you want to try this out make sure to set up a new project by running:
mkdir whatsapp-media-messages cd whatsapp-media-messages npm init -y
Sending Your First Media Message
twiliohelper library by running:
npm install twilio
Create a new file called
index.jsand place the following code ...
Deploying and Running Angular ASP.NET Core Video Chat Applications on Microsoft Azure
With Twilio Programmable Video you can add robust video chat functionality to web applications built with Angular and ASP.NET Core. With the Microsoft Azure App Service you can host your video-enabled apps on a fully managed, enterprise-grade cloud platform. Deployment and configuration are easy and take just minutes.
You will learn how to publish your application to the Azure App Service, and securely configure the app on Azure to use the Twilio Video Chat API with the App Service settings. You’ll be able to try out the production applications’ video chat features and verify that it’s ...
Applications are built from pieces, like packages and modules, but at some point those structures aren’t enough to reduce the size and complexity of the application. The idea behind distributed systems is to break big, monolithic designs into small, independent programs which communicate with each other to exchange data and perform operations.
One of the many variants of distributed systems is the microservices architecture, which structures an application as a collection of loosely coupled services. Services are fine-grained and the communication protocols are lightweight (like the HTTP protocol).
There are few things worth emphasizing about the superiority of microservices, and distributed systems generally, over monolithic architecture:
- Modularity – responsibility for specific operations is assigned to separate pieces of the application ...
Development Environment Setup
Let's start by making sure we have the right software installed and set up that we'll need to use for the rest of this post. Throughout this post, you will need:
- Node.js and npm installed (do this first if you haven't already)
- A free Twilio account with an activated WhatsApp Sandbox
- The Twilio Node library
Here is a good guide to follow in general if you are going to be doing more with Twilio and Node.js and have any more questions.
Sign up for Twilio and activate the Sandbox
Before you can send a WhatsApp message from your web language, you'll need to sign up for a Twilio account or ...
Announcing Twilio Client JS SDK 1.7 GA with Opus Codec Support and Codec Preference API
We’re excited to announce the General Availability of Twilio Client JS 1.7. With this release, Opus, a highly performant codec delivering better audio quality in various network environments, is now supported through the new Codec Preference API.
Compared to G.711 (PCMU), the other codec currently supported by Twilio Client JS, Opus delivers a superior voice quality at less than half the bandwidth (around 40kb/s as opposed to 80kb/s). We highly recommend enabling Opus in your applications to deliver this superior voice quality to your users.
Please refer to our changelog to find download instructions and API documentation.
Getting the Release and Upgrade Path
Upgrading from 1.3, 1.4, 1.5 and 1.6 is super simple. There are no breaking changes and it’s a matter of updating your twilio.js.
How to send text messages from your static site using Netlify, Twilio and serverless functions
It’s exciting times to be a Frontend developer. With the rise of modern technologies such as serverless functions, Frontend engineers can do things that usually only backend engineers could do. This entails deploying scalable sites, sending emails, or creating HTTP endpoints. Due to the power of new service providers and countless APIs, building performant applications has become rather a game of connecting dots than building everything from the ground up.
You can see the final result on 8-bit-revolution.netlify.com. You can go there and tell me how much you love the good old 8-bit style via SMS. If you want to set-up a site similar to “8-bit revolution” you can have a look at the project ...
How to build a CLI with Node.js
Command-line interfaces (CLIs) built in Node.js allow you to automate repetitive tasks while leveraging the vast Node.js ecosystem. And thanks to package managers like
yarn, these can be easily distributed and consumed across multiple platforms. In this post we'll look at why you might want to write a CLI, how to use Node.js for it, some useful packages and how you can distribute your new CLI.
Why create CLIs with Node.js
One of the reasons why Node.js got so popular is the rich package ecosystem with over 900,000 packages in the
npmregistry. By writing your CLIs in Node.js you can tap into this ecosystem including it's big amount of CLI-focused packages. Among others:
Encrypting Cookies with Angular Universal and Node.js
Cookies are a ubiquitous feature of web applications, as anyone clicking GDPR notifications for the last several months has realized. Securely handling the data in those cookies is just as much a requirement as the consent notification. Encrypting your Angular and Node.js application cookies is a way to prevent unauthorized access to confidential and personal information, and it’s easy to implement.
As you know, using an httpOnly cookie helps prevent cross-site scripting (XSS) attacks. (You can learn more in another post.) But what about protecting one registered user’s data against another registered user? Are cookies vulnerable to attacks from trusted users?
This post will demonstrate how authenticated users can get unauthorized access to other users’ cookie data. It will also show you how to encrypt your cookies so the data can only be read by your code, not by users.
The code in this post uses the ...
There are a variety of reasons why you sometimes don't want to give out your phone number to people but still want to receive SMS and be able to reply. Maybe you are trying to sell something on the internet, maybe you want to set up a way for people to report code of conduct violations at an event, or maybe you just don't trust the newly met person that asked for your number. In the past I showed how you can quickly set up a message forwarding with practically no coding using TwiML Bins. However, it doesn't let you respond using that number.
Let's take a look at how we can change that using Twilio Functions. If you prefer to follow along a video, check out this tutorial on our YouTube channel.
Creating a Twilio Function
Before we get started, make sure you have a Twilio account. Sign up ...