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 Donal Toomey
    Best Practices for Twilio Video on Mobile Browsers Best Practices for Twilio Video on Mobile Browsers

    Over the last few months, we have seen a surge in interest from developers building video communication web apps for mobile devices. We have worked closely with customers to overcome obstacles inherent in using video in the browser on a mobile device. Based on these experiences, we've compiled a list of best practices so you can avoid the pitfalls and deliver great video experiences in mobile browsers.

    Mobile Browser Challenges

    A  web app running in a mobile phone web browser is the quickest and easiest way to get into a video call. Just click on the web link from a text message or email and you can be in a video call on your phone in seconds - no app install required.

    However, there are some challenges unique to mobile browsers that do not exist with their desktop counterparts. The top gotchas that often catch developers out are:

    • Another tab …
    Read More
  • By Maciej Treder
    Asynchronous JavaScript: Introducing async and await async-js-async-await.png

    Asynchronous processing is one of the most important aspects of the JavaScript language. JavaScript is a single-threaded language, so it needs a mechanism to deal with the actions like performing time-intensive and potentially unreliable activities like making REST API calls, reading files from the disk, or interacting with user input.

    In JavaScript the mechanism used is an event loop, which processes a callback queue in order from oldest item to newest. Each item in the queue is a message that’s processed completely before moving on to the next next message. Each message is a function that returns a response to code elsewhere in the application. Functions used in this way are called callback functions.

    Because of callbacks, JavaScript can use a number of techniques for getting around its single-threaded nature to implement asynchronous processing. Unfortunately, some of those techniques, JavaScript Promises and RxJS Observables, force you to introduce at …

    Read More
  • By Tilde Thurium
    Gatsby email contact forms with Twilio Functions and React Gatsby email contact forms with Twilio Functions and React

    Today I’ll teach you how to send an email from a Gatsby website using Twilio Sendgrid, Twilio Serverless Functions and React. But first, what is Gatsby and why should you care?

    Gatsby 101

    If you spend time in JavaScript land, you might have heard of the JAMstack -- JavaScript, APIs, and Markup.

    Traditional web apps dynamically generate HTML from templates when the server receives a request. JAMstack websites use static site generators to turn templates into HTML when the site is deployed, instead of when a request comes in. 

    Since plain ol’ HTML can be much faster to serve, JAMstack can give you a huge performance boost. Especially if you’re using a content delivery network. Although, there are limits to the amount of UI complexity static sites can support.

    Gatsby bridges the gap between JAMstack static sites and traditional web apps. You write React components that compile to …

    Read More
  • By Lizzie Siegle
    Build a Hamilton Song Recommendation SMS Bot with Machine Learning ham header

    Hamilton the Musical will start streaming on Disney Plus this Friday, so happy Hamilfilm week! To celebrate, learn how to build a SMS chatbot that recommends the Hamilton song most relevant to you right now using Twilio Programmable SMS and Functions, Microsoft Azure Cognitive Services, and JavaScript.

    See it in-action: text how you’re feeling to +13364295064. The longer and more descriptive your message is, the more data the app has to analyze what Hamilton song you need now!

    sms example

     

    Prerequisites and setting up Azure Cognitive Services

    To follow along with this post, you need three things:

    To use Azure Cognitive Services, …

    Read More
  • By Tilde Thurium
    Sending a SMS from Gatsby with serverless functions and React Send SMS from Gatsby with serverless functions and React

    Today I’ll teach you to send a SMS message from a Gatsby website using Twilio Serverless Functions and React. But first, what is Gatsby and why should you care?

    Gatsby 101

    If you spend time in JavaScript land, you might have heard of the JAMstack -- JavaScript, APIs, and Markup.

    Traditional web apps dynamically generate HTML from templates when the server receives a request. JAMstack websites use static site generators to turn templates into HTML when the site is deployed, instead of when a request comes in. 

    Since plain ol’ HTML can be much faster to serve, JAMstack can give you a huge performance boost. Especially if you’re using a content delivery network. Although, there are limits to the amount of UI complexity static sites can support.

    Gatsby bridges the gap between JAMstack static sites and traditional web apps. You write React components that compile to HTML plus …

    Read More
  • By Emily Shenfield
    Deploy a Word Game in 5 Minutes with Twilio Functions Deploy a Word Game in 5 Minutes with Twilio Functions

    If the number of virtual social gatherings you attend regularly has increased over the past few months, you may have found yourself awkwardly ending a call when all the attendees have run out of things to talk about, or playing the same virtual party game more times than you can count, or perhaps like me you’ve just resorted to reading memes out loud to your friends. If you’re looking to inject more creativity and conversation into your calls, follow along in this post to add a new twist on an old word game to your “Virtual Happy Hour Survival Kit”. Fictionary and this SMS version, BalderText, challenge players to write convincing definitions for uncommon English words to try and trick other players.

    Using Twilio Programmable SMS and Twilio Functions, this post will guide you through deploying and getting ready to play a game of BalderText in under five minutes.

    Requirements …

    Read More
  • By Dave Nugent
    React or Vue: What Framework Are You? With IBM Watson and Twilio Autopilot and Functions header what framework are you

    Which JavaScript framework are you: React, Vue, Angular, Ember, or Backbone? Answer this question by building an intelligent chatbot with JavaScript, IBM Watson, Twilio Functions and Autopilot, and a Naive Bayes Classifier npm module.

    This post was written with Twilio developer evangelist Lizzie Siegle for a workshop and is an adaptation of a chatbot first built on dev.to.

    Prerequisites and Setup

    To follow along with this post, you need three things:

    If you haven't already, follow this blog post to make a Watson Natural Language service, make a new Twilio Function, and then call Watson NLU from said Twilio Function. With your Twilio Function …

    Read More
  • By Alex Dunne
    How to Build an Automated SMS Survey Using Twilio Studio and IBM Watson Tone Analyzer Using Twilio Studio and IBM Watson Tone Analyzer

    Surveys are a great tool to receive feedback from your customers. Timely surveys to new and existing customers can provide enormous insight into how your product or service is performing, and highlight problems you may not know existed.

    In this tutorial, we’ll build an automated SMS survey application that reacts empathetically to customer responses using Twilio Studio, IBM Watson Tone Analyser, and a little bit of JavaScript.

    Upon completion, you will have learned about Twilio’s visual application builder, Twilio Studio, and how to utilize it to build an automated SMS survey workflow. You’ll also learn how to integrate external third-party APIs into the workflow to enhance the application’s functionality. By the end of this article, you will be on your way to building a fully-featured SMS survey that replies based on the customer’s feedback.

    In the following examples, we’re going to tailor the questions towards the hotel industry. …

    Read More
  • By Dominik Kundel
    ASTs - What are they and how to use them Decorative image saying "Abstract Sytnax Trees - What they do and how to use them"

    If you are writing code, chances are that ASTs are involved in your development flow. AST stands for Abstract Syntax Tree and they power a lot of parts of your development flow. Some people might have heard about them in the context of compilers but they are being used in a variety of tools. Even if you don't write general development tools, ASTs can be a useful thing to have in your toolbelt. In this post we'll talk about what ASTs are, where they are used and how you can leverage them.

    What is AST?

    Abstract Syntax Trees or ASTs are tree representations of code. They are a fundamental part of the way a compiler works. When a compiler transforms some code there are fundamentally the following steps:

    1. Lexical Analysis
    2. Syntax Analysis
    3. Code Generation
    Diagram showing how input is transformed into tokens via Lexical Analysis and then into an AST through Syntax Analysis. Lastly it's transformed into output using Code Generation.
    Visualizsation by https://twitter.com/@_lrlna

    Lexical Analysis aka Tokenization

    During this step, code that you wrote is going …

    Read More
  • By Harshil Agrawal
    Secure your Auth0-Powered Application with SMS Alerts from Twilio Secure your Auth0-powered Application with SMS Alerts from Twilio

    The Twilio SMS API empowers developers to programmatically send SMS to users, receive SMS messages, track the delivery of the sent messages, as well as retrieve and modify message history. The SMS API is flexible and can be used for various purposes, some of which can be sending SMS for two-factor authentication, updating users about their orders, or even automating replies of a bot.

    Every application and website needs authentication to securely deliver content to the users and build trust among their users. But what if this trust gets broken? How do you make sure your users are notified for their account activities?

    In this blog post, we will see how we can use the Twilio SMS API and the Auth0 hooks to notify our users when they create an account. We will not only stop there. We will also notify our users every time they change their passwords and …

    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.