通話受信ルートの追加

ここでは、応答Webhookを提供して、仮想番号で着信通話を受信すると、Vonage APIプラットフォームがHTTPリクエストを介してそのWebhookに通知するようにします。

Webhookは、1つのstreamアクションを含むNCCOをVonageに返します。これにより、STREAM_URLにあるファイルから通話に音声が再生されます。

テスト目的のために、次のURLを使用します: https://raw.githubusercontent.com/nexmo-community/ncco-examples/gh-pages/assets/welcome_to_nexmo.mp3

VoiceControllerクラスに次のコードを追加します

[HttpGet("/webhooks/answer")]
public string Answer()
{
    const string STREAM_URL = "https://raw.githubusercontent.com/nexmo-community/ncco-examples/gh-pages/assets/welcome_to_nexmo.mp3";
    var streamAction = new StreamAction{
        StreamUrl = new string[]
        {
            STREAM_URL
        }
    };
    var ncco = new Ncco(streamAction);
    return ncco.ToString();
}