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 Ted Gieschen
    How to Collect Times and Dates in Voice Calls or SMS using JavaScript How to Collect Times and Dates in Voice Calls or SMS using JavaScript

    Twilio offers a wide variety of channels you can use to connect with your customers, for example, through an SMS or Phone Call. One of the ways you can use these channels is to collect data from your customers. Depending on the type of data, this can be a complex undertaking. Collecting individual words or numbers is usually pretty straightforward. However, when asking customers to share specific Times and Dates, this can be far more complex. A typical use-case might be the scheduling of an appointment. This is especially true when allowing customers to communicate in free form (for example, “I would like an appointment next Tuesday at 3 pm”).

    In this blog, I will show you how you can extract Times and Dates during a phone call using JavaScript and serverless Twilio Functions without the need for any 3rd party integrations.


    To build this solution, you will …

    Read More
  • By Naomi Pentrel
    Twilio's Unofficial Vote for the Eurovision Song Contest Twilio's Unofficial Vote for the Eurovision Song Contest

    Eurovision is near and while you can't officially vote just yet, we thought we'd allow the public to vote already - and not just for this year but for ALL Eurovision's that have happened since the beginning of Eurovision. That includes 2020 - the year Eurovision was cancelled.

    How do I vote?

    Text '2022' to one of the following numbers to get the list of all the 2022 participants and their youtube videos. Once you have picked a winner, text “2022 Country” to the same number (e.g. 2022 Germany).

    Netherlands: +3197010253872

    UK: +44 7401 199687

    Sweden: +46 70 192 18 32

    United States: +1 (267) 713-3577

    What about the other years... Could we maybe vote for those too?

    You can text any year from 1956 to 2022 to any of the above numbers and then vote for your favourite song.

    How do I see the results?

    You can see the …

    Read More
  • By Miguel Grinberg
    Synchronized State Variables for React using Twilio Sync Synchronized State Variables for React using Twilio Sync

    State variables are one of the most important building blocks in front end applications developed with the React library. When a state variable is updated, React automatically re-renders any application components that depend on it, ensuring that the application always displays updated information to the user.

    The automatic state update mechanisms in React are fantastic, but they are limited to a single instance of the application. Sometimes, however, an application needs state variables that are automatically synchronized across all running instances of the application. In this tutorial you are going to learn how to create a custom React hook that implements synchronized state variables using Twilio Sync as a cloud storage back end.

    Tutorial demonstration


    To work on this tutorial you will need the following items:

    Read More
  • By Sam Agnew
    Using Event Webhooks for Emails with Twilio SendGrid in Node.js Copy of C02 Blog Text.png

    When sending emails with Twilio SendGrid, sometimes you want to be able to keep track of the status of these emails, such as when a recipient opens the message or reports it as spam. This is made possible by the use of Event Webhooks. Let's walk through how to use Node.js and Express to track the status of emails that you send.

    Prerequisites and dependencies

    Make sure you have the following before moving on:

    • Node.js and npm installed (do this first if you haven't already)
    • A free SendGrid account
    • An email address to test out this project
    • A domain on which you will receive emails. For the purposes of this article, I’m going to use yourdomainhere.com. You will need to replace it with your own domain name.

    We'll need to install the node modules for SendGrid and Express. To install these npm modules, navigate to the directory where …

    Read More
  • By Mingchao Ma
    Integrate Twilio Verify Service with RSA SecurID RSA Verify header

    Many organisations in the banking sector are still using RSA SecurID with hardware tokens for multi factor authentication (MFA). However, employees might forget their hardware token thus won’t be able to login. This leads to high support costs, poor user experience and reduced productivity. This is the exact challenge that one of our customers in banking is trying to address. So we worked together to explore how Twilio Verify Service can be leveraged as an alternative MFA. This will allow their employees to login their protected systems by using a One-Time Password (OTP) delivered to their employee’s mobile phone.

    This blog post will walk you through the steps of how to integrate Twilio Verify service with RSA SecurID.

    The RSA Authentication manager requires that you pin a certificate for the HTTPS endpoint of your SMS provider. This will cause your application to break when the certificates change in the future. …

    Read More
  • By Stephenie Minami Nakajima
    SlackからSMSを送信するNode.jsアプリケーションを開発する方法 SlackからSMSを送信するNode.jsアプリケーションを開発する方法



    Slackで取り扱う情報は多種多様ですが、Slackが提供するSlack APIを使用すると、これまでSlack上で手作業で行っていたことを、自動化できます。SMSの送信も、自動化できることの1つです。

    本稿では、Slack APIとTwilio、Node.jsを使って、SlackからSMSを送信するアプリを構築する方法をご紹介します。




    チャンネル内で/smsとコマンドを送信すると、モーダルが出現し、 その後電話番号とメッセージを入力してSMSを送信します。送信がうまく実行されると、「SMSを送信しました」メッセージがアプリからチャンネルに送信されます。



    • Node.js v16以降とnpm
    • JavaScriptとNode.jsの基礎知識。
    • Slackのワークスペース。作成方法について詳しくは、Slack公式ヘルプセンターを参照してください。
    • Twilioのアカウント。Twilioホームページをブラウザで開き、[今すぐ無料サインアッ]ボタンをクリックするか、Twilioアカウントの作成リンクからサインアップします。このリンクを使用するとアカウントのアップグレード時に10米国ドル相当分のクレジットが追加で付与されま …
    Read More
  • By Phil Nash
    How to build an email contact form with SendGrid and Node.js How to build an email contact form with SendGrid and Node.js

    Displaying your email address on a website can result in your email being scraped and used for spam. One way to get around this, but still allow people to contact you from your website, is to build a contact form.

    In this post you will build a contact form using SendGrid to deliver emails to your inbox without exposing your email address.

    You will build the project with Twilio Functions, but you could adapt the code to use in any Node.js environment.

    How is this different to sending an email with an API?

    When someone fills in a contact form, you might expect to receive an email in your inbox from their email address. However, to maintain a good email sending reputation, SendGrid only allows you to send emails from addresses that you have verified individually or from domains you have authenticated.

    So, instead of using the submitted …

    Read More
  • By Lizzie Siegle
    Celebrate St Patrick's Day: Translate English to Gaelic with Twilio Serverless, SMS, and IBM Watson Copy of C01 Blog Text (3).png

    Celebrate St. Patrick's Day on March 17th by texting a sentence to +13863564094 to translate it to Gaelic, and read on to learn how to build the app using IBM Watson, Twilio Functions, JavaScript, and the Twilio Serverless Toolkit.

    Screen Shot 2022-03-16 at 10.12.41 AM.png


    1. A Twilio account - sign up for a free one here and receive an extra $10 if you upgrade through this link
    2. A Twilio phone number with SMS capabilities - configure one here
    3. Node.js installed - download it here
    4. IBM Cloud account - sign up for a free one here

    Setup IBM Watson

    Go to the IBM Watson Cloud Translator console, select the free Lite plan, and make a new service by clicking Create on the righthand panel.

    watson create service

    Whoop whoop! You've just made y …

    Read More
  • By Phil Nash
    TwilioとReactでSMSを送信する方法 TwilioとReactでSMSを送信する方法

    この記事はPhil Nashこちらで公開した記事(英語)を日本語化したものです。



    クライアント側からREST APIを使うべきでない理由

    技術的には、JavaScriptのクライアント側アプリケーションから直接Twilio REST APIを使いSMSを送信できます。ただし、それを実際に実行すると、Twilio認証情報がサイトを使用中の他人に公開される可能性があります。悪意のあるユーザーは、その認証情報を悪用し、アカウントに高額な請求を発生させる可能性もあります。


    認証情報の悪用を避けるために、Twilio REST APIを実装し、認証情報を晒さずにSMSメッセージを送信する、サーバーサイドアプリケーションを作成します。次に、Reactアプリケーションからバックエンドを呼び出し、認証情報をインターネット上に公開せずに、SMSメッセージを送信します。


    Twilio REST APIを使用し、アプリケーションからテキストメッセージを送信するには、以下の項目が必要になります。

    Read More
  • By Dhruv Patel
    How to Send SMTP Emails in Node.js With SendGrid Send Email in Node.js Using SMTP with Twilio SendGrid

    When it comes to email services in application development, a hosted email API – such as Twilio SendGrid – is the way to go as it offers ways to customize the setup to your needs. However, you may want to send emails through SMTP (Simple Mail Transfer Protocol) if it is already on your existing platform and since it is an email standard that's used universally. Luckily, Twilio SendGrid offers an SMTP Relay service without having to set up your own server. You’ll also still have access to in-depth metrics, analytics tracking, increased deliverability rates and even more SendGrid features through the X-SMTPAPI header.

    In this tutorial, you’ll learn how to send out emails through Twilio SendGrid’s SMTP Relay in Node.js.

    If you have the option and are still deciding whether to integrate SendGrid through our API or SMTP Relay, we highly recommend using our Web API. SMTP …

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