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?


Have you ever been disconnected from a support call while being transferred to someone else? That couldn't have left a great impression on you...

Warm transfer eliminates this problem - it allows your agents to have the ability to dial in another agent in real time.

Today we'll add warm transfer to a Python and Flask application so we can engender warm feelings among customers talking to support.


  1. The first agent becomes available by connecting through the web client.
  2. The second agent becomes available by connecting through the web client.
  3. A customer calls our support line.
  4. クライアントは、最初の担当者が電話に応対するまでしばらく待ちます。
  5. While the first agent is on the phone with the client, he or she dials the second agent into the call.
  6. Once the second agent is on the call, the first one can disconnect. The client and the second agent stay on the call.

さぁ、はじめましょう! GitHubからサンプルアプリケーションをクローンし、下のボタンをクリックして始めてください。

We're Warming Up


First, let's configure the voice web-hook for the Twilio number that customers will dial when they want to talk to a support agent.

ウォーム転送用のTwilio Console

In production, this should be the public-facing URL for your app.

One option to expose a development URL from your local machine is to use ngrok. Your URL would then be something like:



        Twilio Webhookに対するルート


        Awesome, now you've got a webhook in place. Next up, we'll look at some of the code.

        Connect an Agent to a Call

        Here you can see all front-end code necessary to connect an agent using Twilio's Voice Web Client.

        We need three things to have a live web client:

        • ケイパビリティ・トークン(Flaskアプリケーションから提供されます)
        • 担当者ごとの一意の識別子(文字列)
        • Twilio によってトリガーされる各種イベントを処理するためのイベントリスナー





              Twilio 音声通話 Web クライアントに接続するために、ケイパビリティートークンが必要です。





                    For this tutorial we used fixed identifier strings like agent1 and agent2 but you can use any unique application generated string for your call center clients. These identifiers will be used to create outbound calls to the specified agent using the Twilio REST API.

                    When a client makes a call to our Twilio number the application receives a POST request asking for instructions. We'll use TwiML to instruct the client to join a conference room and use the Twilio REST API client to invite (and initiate a call to) the first agent.

                    When providing instructions to the client, we also provide a waitUrl. This URL is another end point of our application and will return more TwiML to SAY welcome to the user and also PLAY some music while on hold. Take a look at the code here.

                    We use the client's CallSid as the conference identifier. Since all participants need this identifier to join the conference, we'll need to store it in a database so that we can grab it when we dial the second agent into the conference.



                          Provide TwiML Instructions For The Client

                          Here we create a TwiMLResponse that will contain a DIAL verb with a CONFERENCE noun that will instruct the JavaScript client to join a specific conference room.


                                Provide TwiML instructions to the client


                                Next up, we will look at how to dial our first agent into the call.


                                Dial The First Agent Into the Call

                                アプリに対し、担当者へのダイヤリングを処理する call モジュールを作成しました。このモジュールでは、Twilio の REST API を使用して新しい通話を作成します。create メソッドは以下のパラメーターを受け取ります。

                                1. from_:Twilio 電話番号
                                2. to:担当者の Web クライアント識別子(agent1 または agent2
                                3. url:通話が接続したときに TwiML 命令を求める URL

                                担当者が Web クライアントで通話に応答すると、コールバック URL に対するリクエストが作成され、クライアントがすでに待機しているカンファレンスに参加するようこの通話に指示が出されます。


                                      With that in mind, let's see how to add the second agent to the call.

                                      Dial The Second Agent Into the Call

                                      When the client and the first agent are both in the call we are ready to perform the warm transfer to a second agent.

                                      The first agent makes a request passing its identifier to allow us to look for the conference_id needed to invite the second agent. Since we already have a call module, we can simply use the call_agent function to connect the second agent.




                                            When the three participants have joined the same call, the first agent has served his or her purpose. Now agent #1 can drop the call, leaving agent #2 and the client to discuss support matters.

                                            It is important to notice the differences between the TwiML each one of the participants received when joining the call:

                                            • Both agent one and two have startConferenceOnEnter set to true.
                                            • For the client calling and for agent two, endConferenceOnExit is set to true.

                                            Translated, this means a conference will start when either agent joins the call. It also means the client or agent #2 disconnecting will hang up the call.





                                                  PythonおよびFlaskを使用して、ウォーム転送を実装できました。 これでエンドユーザーの転送時にサポート通話から切断される

                                                  Now let's look at some other great features Twilio makes it easy to add.


                                                  If you're a Python developer working with Twilio you'll almost certainly love these tutorials:



                                                  ブラウザー 通話

                                                  Twilio クライアントを使って、ブラウザーから電話へ、およびブラウザーからブラウザーへの通話を簡単に行う方法を学びます。


                                                  このチュートリアルをお読みいただき、ありがとうございます。 どんなものを構築されたか(されるのか)、ぜひTwitterでお知らせください

                                                  Agustin Camino Paul Kamp Andrew Baker Kat King Samuel Mendes
                                                  Rate this page:


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