IVR: Screening & Recording with Python and Django

IVR Screening and Recording in Python & Django

This Django sample application is modeled after a typical call center experience, but with more Reese's Pieces.

Stranded aliens can call an agent and receive instructions on how to get off of Earth safely. In this tutorial, we'll show you the key bits of code that allow an agent to send a caller to voicemail, and later read transcripts and listen to voicemails.

このサンプルアプリを自分で実行するには、コードをダウンロードし、GitHub の指示に従ってください

Read how Hulu and IVR with scheduled callbacks on Twilio. Find more examples sample IVR code for many web frameworks on our IVR application page.



When our alien caller chooses a planet, we need to figure out where to route the call. Depending on their input, we will route this call to an extension. Extensions are used to look up an agent. Any string can be used to define an extension.

When our alien caller has made their choice we use the key-press to look up the requested Agent.



        Now that our user has chosen their agent, our next step is to connect the call to that agent.







              Our agent can now be called, but how does our agent interact with this feature? Let's dig into what is happening in the agent's screening call.



              When our agent picks up the phone, we use a <Gather> verb to ask them if they want to accept the call.

              If the agent responds by entering any digit, the response will be processed by our agent/connect_message

              route. This will <Say> a quick message and continue with the original <Dial> command to connect the two parties.


                    これで、エージェントは通話を行えるようになりましたが、エージェントが外出中だった場合はどうなるでしょうか。 このような場合は留守録機能をセットアップすると便利です。

                    Set up the agent's voicemail


                    When Twilio makes a request to our Call action method, it will pass a DialCallStatus argument to tell us the call status. If the status was "completed", we hang up. Otherwise, we need to <Say> a quick prompt and then <Record> a voicemail from the alien caller.

                    また、<Record>actionを記述します。 このルートは通話および録音の終了後に呼び出されます。 ルートは「Goodbye」と読み上げ、そして電話を切り(<Hangup>)ます。


                          Now let's take a step back to see how to actually record the call.



                          When we tell Twilio to record, we have a few options we can pass to the <Record> verb.


                          Notice that we redirect to a URL that is specific to this agent. This is a convenient way to specify which agent was called to produce the voice message. This way we can also save the associated agent together with the voicemail.


                                Legal implications of call recording

                                If you choose to record voice or video calls, you need to comply with certain laws and regulations, including those regarding obtaining consent to record (such as California’s Invasion of Privacy Act and similar laws in other jurisdictions). Additional information on the legal implications of call recording can be found here.

                                Notice: Twilio recommends that you consult with your legal counsel to make sure that you are complying with all applicable laws in connection with communications you record or store using Twilio.

                                Finally, we will see how to view an agent's voicemail.



                                Once we look up the agent, all we need to do is display their recordings. We bind the agent, along with their recordings, to a View.

                                Twilio REST API を介して録音をルックアップできますが、必要なデータはすべて transcribe_callback リクエストにあるので、自分で簡単に格納し、ランドトリップを保存できます。


                                      一丁あがり! 実際の担当者、通話スクリーニング、ボイスメールを使って、IVR を実装できました。



                                      If you're a Python developer working with Twilio, you might want to check out these other tutorials.

                                      このチュートリアルのパート 1:ET 電話ホームサービス - IVR 電話ツリー



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


                                      Thanks for checking out this tutorial! If you have any feedback to share with us, we'd love to hear it. Connect with us on Twitter and let us know what you build!

                                      Martin Mena Maylon Pedroso Kat King Craig Dennis Andrew Baker Jose Oliveros Paul Kamp


                                      We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Community Forums or browsing the Twilio tag on Stack Overflow.



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

                                            Sending your feedback...
                                            🎉 Thank you for your feedback!
                                            Something went wrong. Please try again.

                                            Thanks for your feedback!

                                            Refer us and get $10 in 3 simple steps!


                                            Get link

                                            Get a free personal referral link here


                                            Give $10

                                            Your user signs up and upgrade using link


                                            Get $10

                                            1,250 free SMSes
                                            OR 1,000 free voice mins
                                            OR 12,000 chats
                                            OR more