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

このコードスニペットでは、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.

Prerequisites

If you do not have an application you can create one. Make sure you also configure your webhooks.

Write the code

Add the following to 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"
    }
  }'

View full source

Run your code

Save this file to your machine and run it:

bash send-replying-indicator.sh