NCCOにアウトバウンドコールをかける
このコード・スニペットは、アウトバウンドコールを発信し、通話に応答すると音声合成メッセージを再生します。
音声合成メッセージを再生します。このコードでは
サーバーで answer_url このコード・スニペットを実行するには、リクエストの一部として
リクエストの一部として
例
サンプルコードの以下の変数を置き換える:
| キー | 説明 |
|---|---|
VONAGE_VIRTUAL_NUMBER | Your Vonage Number. E.g. |
VOICE_TO_NUMBER | The recipient number to call, e.g. |
Prerequisites
Execute the following command at your terminal prompt to create the JWT for authentication:
Run your code
Save this file to your machine and run it:
Prerequisites
Create a file named make-an-outbound-call-with-ncco.js and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
Create a class named OutboundTextToSpeechCallWithNcco and add the following code to the main method:
val client = Vonage {
applicationId(VONAGE_APPLICATION_ID)
privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
}Write the code
Add the following to the main method of the OutboundTextToSpeechCallWithNcco class:
val callEvent = client.voice.createCall {
toPstn(VOICE_TO_NUMBER)
from(VONAGE_VIRTUAL_NUMBER)
ncco(
talkAction("This is a text to speech call from Vonage")
)
}Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.voice with the package containing OutboundTextToSpeechCallWithNcco:
Prerequisites
Add the following to build.gradle:
Create a class named OutboundTextToSpeechWithNcco and add the following code to the main method:
Write the code
Add the following to the main method of the OutboundTextToSpeechWithNcco class:
Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.voice with the package containing OutboundTextToSpeechWithNcco:
Prerequisites
Prerequisites
Run your code
Save this file to your machine and run it:
Prerequisites
Run your code
Save this file to your machine and run it:
Prerequisites
Run your code
Save this file to your machine and run it:
試してみる
コードを実行すると VOICE_TO_NUMBER が呼び出され、通話に応答すると音声合成メッセージが流れます。
さらに読む
- 音声通知 - このガイドでは、電話でリストに連絡し、メッセージを伝え、誰がメッセージを受け取ったかを確認する方法を学びます。このような音声ベースのクリティカルアラートは、テキストメッセージよりも持続性があるため、あなたのメッセージに気づいてもらえる可能性が高くなります。さらに、受信者の確認により、メッセージが届いたことを確認することができます。
- 電話会議 - このガイドでは、Vonageが通話に関連付ける2つの概念、レグと会話について説明します。
- Googleダイアログフローによる音声ボット - このガイドでは、Vonage Voice APIを使用したDialogflowボットのサンプルコードを使って、Dialogflowボットと対話する方法を説明します。