NCCOの進捗状況
このコード・スニペットでは、呼び出し元がNCCOのどこまで到達したかを追跡する方法を示している。
を使って notify アクション
例
Prerequisites
npm install expressRun 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 TrackNccoProgress:
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 TrackNccoProgress:
Prerequisites
Install-Package VonageWrite the code
Add the following to TrackNccoController.cs:
[HttpGet("[controller]/webhooks/answer")]
public IActionResult Answer()
{
var host = Request.Host.ToString();
//Uncomment the next line if using ngrok with --host-header option
//host = Request.Headers["X-Original-Host"];
var eventUrl = $"{Request.Scheme}://{host}/webhooks/notification";
var talkAction = new TalkAction() { Text = "Thanks for calling the notification line" };
var notifyAction = new NotifyAction()
{
EventUrl = new[] { eventUrl },
Payload = new FooBar() { Foo = "bar" }
};
var talkAction2 = new TalkAction() { Text = "You will never hear me as the notification URL will return an NCCO" };
var ncco = new Ncco(talkAction, notifyAction, talkAction2);
return Ok(ncco.ToString());
}
[HttpPost("webhooks/notification")]
public async Task<IActionResult> Notify()
{
var notification = await WebhookParser.ParseWebhookAsync<Notification<FooBar>>(Request.Body, Request.ContentType);
Console.WriteLine($"Notification received payload's foo = {notification.Payload.Foo}");
var talkAction = new TalkAction() { Text = "Your notification has been received, loud and clear" };
var ncco = new Ncco(talkAction);
return Ok(ncco.ToString());
}Prerequisites
composer require slim/slim:^3.8 vonage/clientRun your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenv fastapi[standard]Run your code
Save this file to your machine and run it:
Prerequisites
gem install sinatra sinatra-contrib rack-contribRun your code
Save this file to your machine and run it:
試してみる
Vonage番号に電話をかけると、音声合成メッセージが流れます。 通知URLへのリクエスト