Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free

JavaScript posts

  • By Ashley Boucher
    Introducing JS Developer for Technical Content, Ashley Boucher Introducing Ashley Boucher

    GIF with quote "Hey! It's Me!"

    I’m sitting on my friend’s patio, over eight feet away from her, because this is how socializing happens in the time of the coronavirus. She asks me about my new job and I attempt to explain.

    “But what exactly will you be doing?”

    Before responding, I try, in the expanse of only a moment, to distill the complexities and multitudes of both Twilio as a company, and of my new role as a technical editor for the Twilio blog into a single, eloquent, explanatory sentence. I stumble with my words. I wish I could write it down. The truth is, I’m better with a pen and paper. I always have been.

    Writing has been my chosen medium since I first developed the ability to make legible marks, back in kindergarten when my afternoons were spent tracing letters with an oversized pencil.

    A Childhood of Writing

    My first completed body …

    Read More
  • By Shiori Yamazaki
    Understanding Functional Components vs. Class Components in React header - Understanding Functional Components vs. Class Components in React

    In the world of React, there are two ways of writing a React component. One uses a function and the other uses a class. Recently functional components are becoming more and more popular, so why is that?

    This article will help you understand the differences between functional and class components by walking through each one with sample code so that you can dive into the world of modern React!

    Rendering JSX

    First of all, the clear difference is the syntax. Just like in their names, a functional component is just a plain JavaScript function that returns JSX. A class component is a JavaScript class that extends React.Component which has a render method. A bit confusing? Let’s take a look into a simple example.

    import React from "react";
     
    const FunctionalComponent = () => {
     return <h1>Hello, world</h1>;
    };
    

    As you can see, a functional …

    Read More
  • By AJ Saulsberry
    Using RxJS Observables With JavaScript Async and Await rxjs-observables-async-await.png

    There are a number of resources for handling asynchronous tasks in JavaScript, each with its own strengths and suitability to specific tasks. Sometimes a single tool is all that’s necessary to accomplish a task, but there are programming challenges which can be handled more effectively by combining the capabilities of tools.

    RxJS Observables enable you to operate on sequences of data, like the results of a REST API call, as if they were events, acting on new and updated data from the Observable object when the change occurs. They’re great tools to use when the timing of data events is unpredictable, like when you’re dealing with slow or occasionally unreliable web services.

    JavaScript Promises are useful when you need a placeholder for the results of a task that might fail and need to respond differently depending on the task’s success or failure. Promise objects can be used with the JavaScript …

    Read More
  • By Elvis Rozario
    Automatically Trigger Twilio SMS in MongoDB through MongoDB Functions Automatically Trigger Twilio SMS in MongoDB through MongoDB functions

    There are quite a few cases in an application when you want to trigger notifications to users on database changes. One of the most common examples would be updates to feeds. When a new web feed arrives in your database you would want to send a notification to your users regarding this feed.

    Usually, in an application, you might trigger an event after storing the feed in your database, which will asynchronously send a notification to your users. But is that the best solution available out there? Wouldn’t it be a lot better if you could send messages automatically when a document is created or updated in a collection, thus separating it from your business logic?

    Recently, MongoDB Atlas released MongoDB functions as part of their new collaboration with Realm. These functions currently support modern JavaScript (ES6+) syntax and execute in a serverless manner. It is part of their …

    Read More
  • By Tilde Thurium
    Building a telemedicine waiting room with Twilio Video Building a telemedicine waiting room with Twilio Video

    Telemedicine is rapidly changing the healthcare industry. COVID-19 concerns aside, being able to see a doctor’s face without having to commute is a game changer.

    Twilio Video allows developers to craft HIPAA-compliant telemedicine solutions that are fully under your control and tailored to your patients’ needs. Today I’ll show you how to make a telemedicine app using Twilio Video that lets you show a “virtual waiting room” where the patient can hang out until their doctor arrives. For the sake of simplicity, let’s build the front end in vanilla JS without a framework.

    At a high level, here’s the steps we’ll be following:

    • Set up a back end to control access to the application
    • Set up basic front end scaffolding
    • Build the provider experience
    • Build the patient experience

    Screenshot of a telemedicine app. The text says "Welcome to Owl Hospital Telemedicine" and there are 2 smiling, real live people video chatting.

    For impatient types who want to skip straight to the code, the whole project is on GitHub.

    Prerequisites

    • A developer environment …
    Read More
  • By Maciej Treder
    Asynchronous JavaScript: Using Promises With REST APIs in Node.js async-js-apis-nodejs.png

    In JavaScript, like many programming languages, asynchronous processing can be used to handle tasks that take a long time to run or are potentially unresponsive. The JavaScript Promise object provides a way of monitoring their state and serves as a placeholder and container for the data they’ll eventually return — or not.

    Often it doesn’t matter when a Promise returns data and the members of a collection of Promises can be resolved independently without regard to timing. A function can perform asynchronous tasks that don’t depend on the data from, or the success of, other asynchronous tasks.

    But sometimes business rules or program design require that asynchronous actions are dependent on other asynchronous operations. For example:

    • Establishing a remote database connection must be preceded by loading configuration information from the file system.
    • Performing a REST API call to a weather API must be preceded by obtaining the user’s location from …
    Read More
  • By Sam Agnew
    Retrieving Twilio MMS Image URLs with Node.js Copy of Generic Blog Header 4(1).png

    When working with Twilio MMS, you often need to access a URL to the pictures contained in a message. Typically when the message is initially received, the webhook request that Twilio sends to your application will contain MediaUrl properties that you can use directly in your application. But if you want to use the REST API to access a URL to an image contained in a Message Resource, you need to do a little more work, as the only option available to you is the uri of the Media resource:

    message.media().list().then(media => {
      media.forEach(m => {
        const url = 'https://api.twilio.com' + m.uri.replace('.json', '');
        console.log(url);
      });
    });
    

    Let's walk through a …

    Read More
  • By Isabel Hildebrand
    Tracking Time Spent in Meetings With Google Calendar, Twilio, and n8n tracking-time-with-n8n.png

    Time is a commodity that can’t be purchased but, if managed well, you can free up time to spend on the things you love. According to an article by Dorie Clark of Duke University in the Harvard Business Review, tracking your time can give you a better overview of how you spend your time during the week.

    You might realize that you’re spending too much time during the week on meetings. If you are curious to learn exactly how much time — even if you dread the answer — this post is for you!

    In the tutorial that follows you’ll learn how to pull the details of your meetings from your Google Calendar using the Google Calendar API. Then you’ll use Twilio Programmable SMS to send yourself a weekly text message with the total for the previous week. 

    You’ll also learn how to use n8n (pronounced “nodemation”) to create …

    Read More
  • By Phil Nash
    Build a Jira plugin that can send SMS messages using Twilio Build a Jira plugin that can send SMS messages with Twilio

    As a developer, when you think of Atlassian's Jira you probably think of bug tracking or project management for software development, but many organisations use Jira for all sorts of project management and communication. We found this out recently when The Salvation Army in Australia reached out for help sending SMS messages from their Jira powered contact centre.

    Opening up this communication channel led to great results for the Salvos. In this post we are going to see how to build your own Jira plugin that can send SMS messages within your Jira project.

    What we're going to build

    We're going to build a Jira plugin that adds a new view into your Jira project from which you can send SMS messages using the Twilio API. This will be similar to the first version of the plugin we built with the Salvos.

    We need to be able to handle …

    Read More
  • By Miguel Grinberg
    Screen Sharing with JavaScript and Twilio Programmable Video Screen Sharing with JavaScript and Twilio Programmable Video

    The Twilio Programmable Video API allows you to build customized video chat applications on top of the WebRTC standard. In this article, I’m going to show you how to add a screen sharing option to a browser-based Programmable Video application built in JavaScript.

    Screen sharing demo

    Tutorial requirements

    In this tutorial we are going to add a screen sharing feature to the video chat application built with JavaScript and Python on a previous introductory tutorial. To run this application on your computer you need the following 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 or paid Twilio account. If you are new to Twilio get your free account now! This link will give you $10 when you upgrade.
    • A web browser that is compatible with the Twilio Programmable Video JavaScript library (see below …
    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.