Make Outbound Phone Calls with Delphi
In this guide, we'll show you how to use Programmable Voice to make outbound phone calls from your Delphi applications. All you'll need is a voice-capable Twilio phone number, your account credentials, and five minutes to have a boatload of fun at your keyboard.
The code snippets in this guide were written and tested using Delphi 10.2.3. You can view the complete sample project on GitHub.
はじめましょう!
音声通話に対応したTwilio電話番号を購入する
Twilioコンソールでは、通話の発信に対応した利用可能な電話番号を検索、購入できます。 この電話番号は、発信通話を開始する際に発信者番号 (From) として使用します。
Twilioアカウントの認証情報を取得する
First, you'll need to get your Twilio account credentials. They consist of your AccountSid and your Auth Token. They can be found on the home page of the console.
通話を発信する
Now we're ready to make an outbound phone call using the provided TTwilioClient
.
TTwilioClient
is a sample class that encapsulates the HTTP calls that need to be made to the Twilio REST API. Feel free to extend it or rework it for your needs.
通話を発信する際に特筆すべき、いくつかの重要なパラメーターがあります。
<?xml version="1.0" encoding="UTF-8"?> <Response> <Say>Thanks for calling!</Say> </Response>
And here's some TwiML you might use to respond to an incoming SMS message:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Message>We got your message, thank you!</Message> </Response>
すべてのTwiMLドキュメントはルートの<Response>要素と、その中に含まれるひとつ以上の動詞からなります。 動詞とは、電話をかけてきた人にあいさつする<Say>や、受信メッセージへの返信としてSMSを送信する<Message>といったような、Twilioにおこなってほしいアクションのことです。 TwiMLで実行できることがあまねく網羅されたリファレンスについては、TwiML APIリファレンスを参照してください。
もちろん、通話を発信するために使用するTwiMLはこの例のような静的なファイルである必要はありません。 ご自身のサーバー側コードでTwiMLを動的に生成し、通話の発信に使用することもできます。 TwiMLを生成するASP.NETサーバーのサンプルを参照するには、着信通話ガイドをご確認ください。
楽しいプログラミングを!
ヘルプが必要ですか?
誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。