Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now


Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?



At its core, setting up a standardized workflow is about enabling your service providers (agents, hosts, customer service reps, administrators, and the rest of the gang) to better serve your customers.

To illustrate a very real-world example, today we'll build a Node.js and Express webapp for finding and booking vacation properties — tentatively called Airtng.


  1. ホストが貸別荘の一覧を作成します
  2. A guest requests a reservation for a property
  3. ホストには予約リクエストを知らせるSMSが受信されます。 ホストは予約を「承諾」または「否認」します
  4. The guest is notified whether a request was rejected or accepted

AirbnbがTwilio SMSを使用して、世界中の6千万以上の旅行者たちに対するレンタル体験を明解にしている方法を学びましょう。


We'll be using the Twilio REST API to send our users messages at important junctures. Here's a bit more on our API:

Ready to go? Boldly click the button right after this sentence.

Let's Boldly Go to the Next Step

Authenticate Our Users

For this workflow to work, we need to handle user authentication. We're going to rely on Passport for Node.js.

Each User will need to have a countryCode and a phoneNumber which will be required to send SMS notifications later.


        Next let's model the vacation properties.


        In order to build our rentals company we'll need a way to create the property listings.

        Property はそれを作成した User(今後このユーザーをホストと呼ぶ)に属し、descriptionimageUrl の 2 つのプロパティーだけが含まれます。


              The Vacation Property Model


              Next up, the reservation model.

              Reservation Model

              Reservation モデルは、このアプリケーションに対するワークフローの中心です。


              • 予約を実行した guest
              • The vacation_property the guest is requesting (and associated host)
              • 予約のステータス: pending(保留)、confirmed(承認)、またはrejected(否認)



                    Next, let's look at triggering the creation of a new reservation.


                    The reservation creation form holds only a single field field: the message that will be sent to the host when reserving one of her properties. The rest of the information necessary to create a reservation is taken from the vacation property.

                    A reservation is created with a default status pending, so when the host replies with an accept or reject response our application knows which reservation to update.




                          In the next step, we'll take a look at how the SMS notification is sent to the host when the reservation is created.



                          This is where we use Twilio Node Helper Library to send an SMS message to the host, using our Twilio phone number. As you can see, sending SMS messages using Twilio is just a few lines of code.

                          Now we just have to wait for the host to send an SMS response accepting or rejecting the reservation so we can notify the guest and host that the reservation information is updated.

                                Notify through SMS the host of the new reservation

                                Send out reservation notifications

                                Notify through SMS the host of the new reservation

                                次のステップでは、ホストの SMS レスポンスの処理方法と設定方法を示します。

                                Handle Incoming Messages

                                The reservations/handle endpoint handles our incoming Twilio request and does three things:

                                1. 着信ユーザーから保留中の予約がないかチェックする
                                2. 予約のステータスを更新する
                                3. ホストに応答し、ゲストに通知を送信する

                                Set Up Twilio Webhooks

                                In the Twilio console, you should change the 'A Message Comes In' webhook to call your application's endpoint in the route /handle:

                                SMS Webhook

                                One way to expose your machine to the world during development is to use ngrok. Your URL for the SMS web hook on your phone number should look something like this:


                                An incoming request from Twilio comes with some helpful including the From phone number and the message Body.

                                From パラメーターを使って、ホストをルックアップし、保留中の予約がないかチェックします。予約がある場合は、メッセージ本文を使って、その予約が受諾されたのか却下されたかのかをチェックします。


                                      Deal with host responses


                                      In the last step, we'll use Twilio's TwiML and instruct Twilio to send SMS messages to the guest.

                                      TwiML レスポンス

                                      After updating the reservation status, we must notify the host that he/she has successfully confirmed or rejected the reservation. If no reservation is found, we send an error message instead.

                                      If a reservation is confirmed or rejected we send an additional SMS to the guest to pass along the news.

                                      We use the verb Message from TwiML to instruct Twilio's server that it should send SMS messages.




                                            And that's a wrap! Next let's take a look at other features you might enjoy in your application.



                                            Node.js goes great with a helping of Twilio... let us prove it:

                                            IVR: フォンツリー

                                            IVR(interactive voice response:自動音声応答)システムで、発信者を適切な担当者および情報に簡単にルーティングできます。 


                                            音声通話または SMS テキストメッセージを介して調査を実施し、ユーザーから構造化データを迅速に収集します。


                                            Thanks for checking this tutorial out! Tweet to us @twilio with what you're building!

                                            Agustin Camino Jose Oliveros David Prothero Kat King Samuel Mendes Paul Kamp Andrew Baker
                                            Rate this page:


                                            誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。