Twilio Functions posts

I always used to find myself getting into unwanted social situations that I could never get out of. As the engineer I am, I decided it’d be fun to build and publish a quick solution to this using my toolbelt here at Twilio: How to Escape Pesky Situations using Twilio Functions and TwiML Bins. This solution allowed me to text my “friend” Joanna – an Amazon Polly voice – a key phrase which would trigger Joanna to call me and respond as if there was an emergency using a human-like synthesized speech.
This solution then made me wonder what other fun ways Joanna could help me out. Since it’s also National Anti-Boredom Month (July), I started focusing on ways to tackle boredom and pass time.
Whether it’s walking home from the subway or waiting in line at the store I always find myself needing to kill time. I could …

Twilio acquired Segment last year to help developers unify customer data across every customer touchpoint. I held off on using Segment for a while because I thought Segment was only for businesses, but I learned recently that I, an indie developer, have a use case for it. Read on to learn how to use Segment and Twilio Serverless to send SMS notifications when someone visits your website.
Do you prefer learning via video more? Check out this TikTok summarizing this tutorial in two minutes!
Prerequisites
To follow along with this post, you need three things:
- A Twilio account - sign up for a free one here and receive an extra $10 if you upgrade through this link
- A Twilio phone number with SMS capabilities - configure one here
- Segment account - sign up for a free one here
Add a Segment Source
First off, we need to add …

この記事はPhil Nashがこちらで公開した記事(英語)を日本語化したものです。
Webサイトにメールアドレスを公開すると、スクレーピングされ、スパムに使用されるおそれがあります。この問題を回避し、同時に自身のWebサイトからメールで問い合わせを受け取れるようにする方法の一つとして、問い合わせフォームを構築することがあります。
本稿では、Twilio SendGridベースの開発プロジェクトの一例として、ウェブサイト上で問い合わせフォームを構築し、メールアドレスを公開することなく問い合わせのメールを受け取れるようにする方法を説明します。
プロジェクトはTwilio Functionsも使って構築しますが、本稿でご紹介するコードはあらゆるNode.js環境での使用に対応しています。
APIによるメール送信との違い
ユーザーがお問合せフォームを送信した際は、お問合せフォームを入力した人のメールアドレスを送信元とするメールがウェブサイト運営者に送信されることがよくあります。しかし、メール送信に関する信頼性を維持するため、Twilio SendGridは単一送信元として検証されたアドレス、または認証済みのドメインからの送信しか許可しません。
そのため、提供されたメールアドレスをfrom
アドレスとして使用する代わりに、reply-to
アドレスに設定できます。この方法であれば、Twilio SendGridは認証済みメールアドレスからメールを送信する一方で、受信 …

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 …

背景
「サーバーレス(Serverless)」というキーワードは近年脚光を浴び、さまざまな分野でサーバーレスを用いたソリューションが構築されています。本稿では、サーバーレス開発の概念と、Twilioが提供するサーバーレス環境である、Twilio Functionsを使った開発方法をご紹介します。
サーバーレスとは?
サーバーレスは、開発者がサーバーの構築や管理をすることなくアプリケーションを開発および実行できるクラウドを中心とした開発メソッドです。
サーバーレスアーキテクチャが誕生する前は、小さなプログラムであっても、そのプログラムを実行するサーバーを用意しなければなりませんでした。それだけでなく、用意したサーバーを運用し、常にリソースの使用状況を監視したり、脆弱性に対してパッチ適用をしたりと、維持管理が必要でした。
しかし、サーバーレスアーキテクチャでは、プログラムさえ構築してしまえば、利用者がサーバーの維持管理を行う必要がありません。デプロイされたアプリケーションは需要に応じて自動的に拡張・縮小し、セキュリティなどの管理もサーバーレス環境の提供側が行います。これにより、運用コストの低減やリソースの最適化が期待できます。
「サーバーレス」と言いますが、「サーバーが物理的に存在しない」という意味ではありません。サーバーが抽象化されていて、開発者が設計および運営上サーバーの管理を意識しなくてもいい、ということです。
Twilio Functionsとは?
Twilio Functionsは、Twilioが提供するサーバーレス環境です。Twilioアカウ …

In this article you’ll learn how to send an SMS using Vue 3 on the front end and Twilio Functions on the backend. Because Vue is a front end framework, you’ll use Twilio functions to handle sending a message and to avoid exposing your Twilio credentials.
To demonstrate these concepts, you’ll build a Vue app with a button. When the button is clicked, a POST
request will be made to your API. The API will send a message and then return a response back to your Vue application.
Prerequisites
In order to follow along with this tutorial, you’ll need these tools and technologies:
- npm or yarn
- Node.js installed on your machine
- A free Twilio account (if you sign up with this link, we’ll both get $10 in Twilio credit when you upgrade!)
- A Twilio phone number
Create your API with Twilio Functions
Create a new Function Service

Have you ever needed an out in a sticky situation? Maybe it’s a bad date, an awkward run-in, or you simply just want to leave, we’ve all been there. Here’s a nifty solution you can build yourself! Whenever needed, you can use your Twilio number to bail you out with a faux phone call in a few steps.
In this tutorial, you will learn how to leverage Twilio Functions with TwiML Bins to set up a phone service that will call your personal phone number whenever you send an SMS message to your Twilio number. This phone service will utilize synthesized speech to act as your “friend”.
Prerequisites
- A Twilio account - Sign up for free using this link and receive $10 in credit when you upgrade your account!
- A Twilio phone number.
Using TwiML Bins
TwiML Bins are a serverless solution that allows you to provide Twilio-based instructions …

When building an Interactive Voice Response, or IVR, system with Twilio you might start off using text-to-speech to read out your prompts. As you move to production you may want to replace the text-to-speech with real recordings.
In this post you will learn how to use the Twilio CLI Assets Plugin to store your recordings in a Twilio Assets service and use them in a Twilio Studio IVR application.
Let's build an IVR
To see this in action, let's put together a quick IVR system in Twilio Studio. To do this you will need a Twilio account. If you don't have one yet, sign up for a free Twilio account here and receive $10 credit when you upgrade.
Open the Studio dashboard in the Twilio console and create a new Flow. Give your new Flow a name and click Next.
Select the IVR/Phone Tree template …

Using Twilio's Super Network, you can quickly buy phone numbers from around the world. You can even specify a specific area code to buy a phone number that is local to a certain state, territory, or region.
With Twilio Voice, you can quickly integrate voice communication into your applications. For the application in this tutorial, you'll use Twilio phone numbers, Twilio Voice, and Twilio Functions to create a proxy phone number!
What do I mean by a proxy phone number? Before explaining that, I will discuss a similar concept. In web development, there's a concept of "reverse proxies". When you send HTTP requests to a reverse proxy, the reverse proxy forwards the traffic to a web server on a private network. This way the web server still serves a website but isn't exposed directly to the internet adding benefits like security, performance enhancements, and much more.
Similarly, …

この記事はTwilio Developer AdvocateのPhil Nashがこちらで公開した記事(英語)を日本語化したものです。
Twilio CLIは、Twilioの開発者にとって便利なツールです。 コマンドラインから手軽にTwilioのすべてのAPIにアクセスできるだけでなく、電話番号の管理や、ローカル環境でWebhook URLにワンステップでアクセスできるコマンド、プラグインシステムなど数多くの機能を提供します。CLIプラグインはCLIのコア機能を拡張し、Flexプラグインの構築と管理、アクセストークンの生成、Twilio Functionsを使った構築、そして今回のAssetsプラグインによるTwilio Assetsサービスへのアセットのアップロードなどを可能にしてくれます。
この記事では、Assetsプラグインの使い方をご紹介した上で、このプラグインを作った経緯を詳しくお話しします。
Assetsプラグインとは?
Assetsプラグインでは、画像や音声ファイルなどのアセットの保管先として使用できるAssetsサービスを作成し、アセットのアップロードや管理が行えます。作成したAssetsサービスはTwilioのアプリケーションで使用できます。たとえば、音声ファイルをアップロードして、Twilio Voiceを利用した音声通話中に<Play>
動詞で再生するファイルとして使用したり、MMSでユーザーに送信する画像やWhatsAppメディアメッセージをアップロードしたりすることができます。
Assetsプラグインの使い方
Asse …