返信インジケーターの送信

このコードスニペットでは、Messages API を使って WhatsApp メッセージに返信インジケータを送信する方法を説明します。

各コード・スニペットで使用されているすべての変数の説明を以下に示します:

キー説明
JWT

Used to authenticate your request. See Authentication for more information, including how to generate a JWT.

GEOSPECIFIC_MESSAGES_API_URL

The URL for the Geo-specific Messages API endpoint. One of https://api-eu.nexmo.com/v1/messages, https://api-us.nexmo.com/v1/messages, https://api-ap.nexmo.com/v1/messages.

MESSAGES_MESSAGE_ID

The UUID of the specific message to mark as read.

前提条件

申込書をお持ちでない場合は、ひとつ作るウェブフックの設定 もご確認ください。

コードを書く

send-replying-indicator.sh に以下を追加する:

curl -X PATCH "${GEOSPECIFIC_MESSAGES_API_URL}/${MESSAGES_MESSAGE_ID}" \
  -H "Authorization: Bearer "$JWT\
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d $'{
    "status": "read",
    "replying_indicator": {
      "show": true,
      "type": "text"
    }
  }'

全文を見る

コードを実行する

このファイルをあなたのマシンに保存し、実行する:

bash send-replying-indicator.sh

前提条件

申込書をお持ちでない場合は、ひとつ作るウェブフックの設定 もご確認ください。

Install-Package Vonage

コードを書く

MarkAsReadWithStatusIndicator.cs に以下を追加する:

var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH);
var vonageClient = new VonageClient(credentials);
await vonageClient.MessagesClient.UpdateAsync(WhatsAppUpdateMessageRequest.Build(MESSAGES_MESSAGE_ID, new WhatsAppReplyingIndicator(true)));

全文を見る