SMSの受信

SMSを受信するには

Prerequisites

Add the following to build.gradle:

Write the code

Add the following to the main method of the ReceiveMessage class:

View full source

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.sms with the package containing ReceiveMessage:

gradle run -Pmain=com.vonage.quickstart.kt.sms.ReceiveMessage

Vonage DashboardでWebhookエンドポイントを設定します。

VonageがWebhookにアクセスする方法を知るには、Vonageアカウントで設定する必要があります。

コード・スニペットでは、ウェブフックは次の場所にあります。 /webhooks/inbound-sms.Ngrok を使用している場合、Webhook を設定する必要があります。 Vonage Dashboard API 設定ページ という形式である。 https://demo.ngrok.io/webhooks/inbound-sms.交換 demo というフィールドにエンドポイントを入力します。 インバウンドメッセージ用Webhook URL:

試してみる

これで、Vonage番号にSMSを送信すると、コンソールにログが記録されるはずです。メッセージオブジェクトには以下のプロパティが含まれています: