インバウンドコールに接続する
このコードスニペットでは、インバウンドコールをアウトバウンドコールで別の相手に接続する方法を説明します。
例
サンプルコードの以下の変数を置き換える:
| キー | 説明 |
|---|---|
VONAGE_VIRTUAL_NUMBER | Your Vonage Number. E.g. |
VOICE_TO_NUMBER | The recipient number to call, e.g. |
Prerequisites
Write the code
Add the following to connect-an-inbound-call.js:
const Express = require('express');
const app = new Express();
const onInboundCall = (_, response) => {
const ncco = [
{
action: 'connect',
from: VONAGE_VIRTUAL_NUMBER,
endpoint: [
{
type: 'phone',
number: VOICE_TO_NUMBER,
},
],
},
];
response.json(ncco);
};
app.get('/webhooks/answer', onInboundCall);
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
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 ConnectInboundCall:
Prerequisites
Add the following to build.gradle:
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 ConnectInboundCall:
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:
試してみる
サーバーをオープン・インターネットに公開する必要がある。開発中は ングロク そのために
Vonage番号に電話をかけると、自動的に指定した番号につながります。
の代わりに指定した番号に自動的に接続されます。 VOICE_TO_NUMBER.
さらに読む
- インタラクティブ・ボイス・レスポンス(IVR) - ユーザーがキーパッドで情報を入力し、音声応答を聞くための自動電話システムを構築する。
- Googleダイアログフローによる音声ボット - このガイドでは、Vonage Voice APIを使用したDialogflowボットのサンプルコードを使って、Dialogflowボットと対話する方法を説明します。
- マスクド・コーリング - ユーザー同士の通話を可能にし、実番号を非公開にする。
- 電話会議 - このガイドでは、Vonageが通話に関連付ける2つの概念、レグと会話について説明します。
- コールトラッキング - キャンペーンごとに異なる番号を使用し、着信を追跡することで、どのキャンペーンがうまくいっているかを把握できます。このガイドでは、着信を処理し、別の番号に接続し、Vonageの各番号に電話をかけた電話番号を追跡する方法を説明します。