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

Code, Tutorials and Hacks

  • By Paul Kamp
    Personalize SMS Marketing Communications with Twilio and Segment personalize SMS Twilio Segment

    Personalized communications are powerful. The right message, at the right time, on the right channel is the difference between a customer for life – and a lifelong detractor. Whether you're in real estate, medicine, finance, retail, or really any industry, timely and useful communications are essential to keep your customers happy.

    This post will show you how to personalize an SMS to a customer on an e-commerce page using Segment and Twilio Programmable SMS.

    Let's build something timely!

    Prerequisites

    Before we get started, you'll need to sign up for a few accounts.

    And with that, let's get started!

    Set up a source in Segment

    With Segment, you create a source for every site or app (or device!) you'd like to track …

    Read More
  • By Matthew Gilliard
    How to send SMS at scale with Twilio Title: How to send SMS at scale with Twilio

    If you want to send a single SMS using Twilio you'll need a Twilio account, a phone number to send them from, and of course you'll need to know the destination phone number and the content of the message. Once you have these you can send your message with a single API call either with a direct HTTP request, or using any of our helper libraries. Check out our Programmable SMS Quickstarts for more details.

    What if you need to send a hundred messages? Or a thousand? Or even more? In this post I'll talk through the challenges you may face as you scale up and how to get past them. Code samples will be in Java but the same principles apply with any programming language.

    Sending a single SMS

    Sending one SMS with Java is covered in this blog post. Feel free to go and read it, …

    Read More
  • By Robert Alford
    Build a Contact Form for a Python Django Application with Twilio SendGrid Build a Contact Form for a Python Django Application with Twilio SendGrid

    A contact form is a common feature of many websites that provides a way for users to get in touch with the site’s administrators without having to open their email or hop on the phone. In a Python Django application, a contact form can be used to store a user’s contact information in the site’s database. And with Twilio SendGrid, we can also trigger an automated email containing that information as soon as the form is successfully submitted.

    In this tutorial, we will build a simple contact form for a Django web application that does just that.

    Project screenshot

    Tutorial requirements

    • Python version 3.6 or higher. If you do not have Python installed on your computer, you can download a free installer here.
    • A free Twilio SendGrid account. Sign up here to send up to 100 emails per day completely free of charge.
    • The Django web framework. Django is a fully …
    Read More
  • By Ashley Boucher
    Transcribe a Voice Message in Node.js with Twilio Functions voicetranscribe.png

    In this tutorial you’ll leverage Twilio Programmable Voice to receive phone calls at your Twilio phone number, and transcribe any voice messages left by the caller. This guide can be used as a foundation to build your own voicemail system.

    Prerequisites

    To get started with this tutorial, you’ll need the following:

    Create a new Twilio Functions Service

    Through Twilio, you can configure a webhook that will handle any incoming calls to your Twilio phone number.

    You’ll need a place to host the code for the webhook - this could be your own server, or locally running application, but for this tutorial you’ll use Twilio Functions. Twilio Functions is a serverless environment that lets you deploy backend services without the overhead of setting …

    Read More
  • By Diane Phan
    How to Send a Picture on WhatsApp Using Twilio and Python header - How to Send a Picture on WhatsApp Using Twilio and Python

    The WhatsApp Business API from Twilio is a powerful, yet easy to use service that allows you to communicate with your users on the popular messaging app.

    In this article, we’ll walk you through how you can develop a functional Python program to send an image to a user through WhatsApp.

    Twilio WhatsApp console with an image and message "check out this owl!"

    Prerequisites

    To follow this tutorial you need the following items:

    The Twilio WhatsApp sandbox

    Twilio provides a WhatsApp sandbox, where you can easily …

    Read More
  • By Valeriane Venance
    Send a WhatsApp Message in 30 Seconds with Ruby how-to-send-whatsapp-message-ruby

    Do I need to introduce WhatsApp? If you are reading this article, you are probably familiar with it, but in case you don't, WhatsApp is a cross-platform centralized messaging and voice-over-IP service that allows people from all over the world to communicate via text and voice calls.

    In this tutorial, you will learn how to send your first WhatsApp message using the Ruby programming language and Twilio.

    A bit of configuration, 30 seconds of code and you’ll be done!

    Requirements

    To follow along with me, you will need:

    Getting started

    Create a new folder called ruby-whatsapp on your computer, this is where we are going to create our code files.

    Install dependencies

    We will need the following gems:

    • bundler for avoiding permissions error
    • twilio-ruby …
    Read More
  • By Miguel Grinberg
    How to Send an SMS in FastAPI with Twilio How to Send an SMS in FastAPI with Twilio

    Twilio is all about powering communication and doing it conveniently and fast in any language. But if you have a Python application written with the asyncio package, it may not be completely clear how to translate the examples from the documentation into non-blocking code that works well with an asynchronous loop.

    In this tutorial you’ll learn how to properly deliver SMS notifications from a FastAPI application. The techniques shown here are also applicable to other asyncio frameworks.

    Project demo

    Tutorial requirements

    Read More
  • By Mia Adjei
    Grant Video Access Tokens with Your Express + TypeScript Video API Grant Video Access Tokens with Your Express + TypeScript Video API

    So you've built a video API with Twilio Programmable Video, Node.js, TypeScript, and Express. You've added CORS support so that your future video app will be able to access resources on your server. What's next?

    In order for users to actually be able to connect to video rooms in your app, they will need to be authenticated using an access token. In this tutorial, you'll update your Express + TypeScript video API to add a new route that grants access tokens to the users who will be using your video app. Let's get started!

    Prerequisites

    You will need:

    • A free Twilio account. (If you register here, you'll receive $10 in Twilio credit when you upgrade to a paid account!)
    • Node.js (version 14.16.1 or higher) and npm installed on your machine.
    • HTTPie or cURL.
    • The code from the previous tutorial (see below).

    The rest of this tutorial builds on …

    Read More
  • By Mia Adjei
    Add CORS Support to Your Express + TypeScript API Add CORS Support to Your Express + TypeScript API

    Imagine you've just built a great API using Node.js, Express, and TypeScript. You've also built a client-side web app and are ready to fire it up in your browser, get it talking to your server, and hopefully share it with the world.

    You open up a browser window and navigate to where your app is running, then you pop open the console in your developer tools. Your app makes its first API call to your server...but then, instead of the data you're expecting to see populate your app, you see an error like the one below in your console:

    Access to fetch at 'http://localhost:5000/rooms' from origin 'http://localhost:3000' 
    has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present 
    on the requested resource. If an opaque response serves your needs, set the 
    request's mode to 'no-cors' to fetch the resource with CORS disabled.
    

    Yikes! This error is due to Cross-Origin Resource …

    Read More
  • By Phil Nash
    Web Speech APIを利用しブラウザで音声を認識する方法 Speech recognition browser web speech api jp

    この記事はTwilio Developer EvangelistのPhil Nashこちらで公開した記事の日本語版です。

    Web Speech APIには、音声合成(text to speech)と、音声認識(speech to text)という2つの機能があります。以前の記事では音声合成について解説しましたが、今回はSpeechRecognition APIを利用したブラウザの音声認識、音声書き起こし方法について解説します。

    ユーザーが発する音声コマンドを認識できれば、通常よりも没入感のあるインターフェースを提供でき、音声操作を好むユーザーを獲得しやすくなります。2018年のGoogleの報告によると、全世界のオンライン人口のうち27%がモバイルデバイスで音声検索を使用しています。今回解説するブラウザの音声認識機能を用いて、あなたのWebアプリケーションで基本的な音声検索からインタラクティブbotまで、多岐にわたる機能を提供できます。

    次のセクションからAPIのしくみを理解し、何ができるか実際に確認してみましょう。

    必要なもの

    APIを実際に体験できるサンプルアプリケーションを作成するために次のツールを用意します。


    今回はHTML、CSS、JavaScriptを使用してアプリケーションを作成します。作業用の新しいディレクトリを作成し、このディレクトリにstarter HTMLCSSを保存します。保存したHTMLファイルをブラウザで開くと以下のスクリーンショットと同じ画面が表示されます。

    speech to text sample app

    次のセクション …

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