

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# AWS End User Messaging Social のメッセージとイベント形式
<a name="managing-event-destination-dlrs"></a>

イベントの JSON オブジェクトには、 AWS イベントヘッダーと WhatsApp JSON ペイロードが含まれます。JSON WhatsApp 通知ペイロードと値のリストについては、WhatsApp Business Platform Cloud API [リファレンスの「Webhooks Notification Payload](https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components) Reference」と[「Message Status](https://developers.facebook.com/docs/whatsapp/conversation-types#message-status)」を参照してください。 *WhatsApp *

## AWS エンドユーザーメッセージングソーシャルイベントヘッダー
<a name="managing-event-destination-dlrs_body"></a>

イベントの JSON オブジェクトには、 AWS イベントヘッダーと WhatsApp JSON が含まれます。ヘッダーには、WhatsApp Business Account (WABA) の AWS 識別子と ARNs と電話番号が含まれます。

```
{
  "context": {
    "MetaWabaIds": [
      {
        "wabaId": "1234567890abcde",
        "arn": "arn:aws:social-messaging:us-east-1:123456789012:waba/fb2594b8a7974770b128a409e2example"
      }
    ],
    "MetaPhoneNumberIds": [
      {
        "metaPhoneNumberId": "abcde1234567890",
        "arn": "arn:aws:social-messaging:us-east-1:123456789012:phone-number-id/976c72a700aac43eaf573ae050example"
      }
    ]
  },
  "whatsAppWebhookEntry": "{\"...JSON STRING....",
  "aws_account_id": "123456789012",
  "message_timestamp": "2025-01-08T23:30:43.271279391Z",
  "messageId": "6d69f07a-c317-4278-9d5c-6a84078419ec"
}
//Decoding the contents of whatsAppWebhookEntry
{
//WhatsApp notification payload
}
```

前述の例のイベント:
+ {{1234567890abcde}} は Meta の WABA ID です。
+ {{abcde1234567890}} は Meta の電話番号 ID です。
+ {{fb2594b8a7974770b128a409e2example}} は WhatsApp Business Account (WABA) の ID です。
+ {{976c72a700aac43eaf573ae050example}} は電話番号の ID です。

## メッセージを受信するための WhatsApp JSON の例
<a name="managing-event-destination-dlrs-example-receive-text"></a>

以下は、WhatsApp からの受信メッセージのイベントレコードを示しています。で WhatsApp から受信した JSON `whatsAppWebhookEntry`は JSON 文字列として受信され、JSON に変換できます。フィールドとその意味のリストについては、[「WhatsApp Business Platform Cloud API リファレンス」の「Webhooks Notification Payload](https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components) *Reference WhatsApp*」を参照してください。

```
{
  "context": {
    "MetaWabaIds": [
      {
        "wabaId": "1234567890abcde",
        "arn": "arn:aws:social-messaging:us-east-1:123456789012:waba/fb2594b8a7974770b128a409e2example"
      }
    ],
    "MetaPhoneNumberIds": [
      {
        "metaPhoneNumberId": "abcde1234567890",
        "arn": "arn:aws:social-messaging:us-east-1:123456789012:phone-number-id/976c72a700aac43eaf573ae050example"
      }
    ]
  },
  "whatsAppWebhookEntry": "{\"...JSON STRING....",
  "aws_account_id": "123456789012",
  "message_timestamp": "2025-01-08T23:30:43.271279391Z",
  "messageId": "6d69f07a-c317-4278-9d5c-6a84078419ec"
}
```

[jq](https://jqlang.org/) などのツールを使用して、JSON 文字列を JSON に変換できます。以下は JSON `whatsAppWebhookEntry` 形式の です。

```
{
  "id": "503131219501234",
  "changes": [
    {
      "value": {
        "messaging_product": "whatsapp",
        "metadata": {
          "display_phone_number": "14255550123",
          "phone_number_id": "46271669example"
        },
        "statuses": [
          {
            "id": "wamid.HBgLMTkxNzM5OTI3MzkVAgARGBJBMTM4NDdGRENEREI5Rexample",
            "status": "sent",
            "timestamp": "1736379042",
            "recipient_id": "01234567890",
            "conversation": {
              "id": "62374592e84cb58e52bdaed31example",
              "expiration_timestamp": "1736461020",
              "origin": {
                "type": "utility"
              }
            },
            "pricing": {
              "billable": true,
              "pricing_model": "CBP",
              "category": "utility"
            }
          }
        ]
      },
      "field": "messages"
    }
  ]
}
```

## メディアメッセージを受信するための WhatsApp JSON の例
<a name="managing-event-destination-dlrs-example-receive-media"></a>

受信メディアメッセージのイベントレコードを次に示します。メディアファイルを取得するには、GetWhatsAppMessageMedia API コマンドを使用します。フィールドとその意味のリストについては、[「Webhooks Notification Payload Reference](https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components)」を参照してください。

```
{
//AWS End User Messaging Social header
}
//Decoding the contents of whatsAppWebhookEntry
{
  "id": "365731266123456",
  "changes": [
    {
      "value": {
        "messaging_product": "whatsapp",
        "metadata": {
          "display_phone_number": "12065550100",
          "phone_number_id": "321010217760100"
        },
        "contacts": [
          {
            "profile": {
              "name": "Diego"
            },
            "wa_id": "12065550102"
          }
        ],
        "messages": [
          {
            "from": "14255550150",
            "id": "wamid.HBgLMTQyNTY5ODgzMDIVAgASGCBDNzBDRjM5MDU2ODEwMDkwREY4ODBDRDE0RjVGRkexample",
            "timestamp": "1723506230",
            "type": "image",
            "image": {
              "mime_type": "image/jpeg",
              "sha256": "BTD0xlqSZ7l02o+/upusiNStlEZhA/urkvKf143Uqjk=",
              "id": "530339869524171"
            }
          }
        ]
      },
      "field": "messages"
    }
  ]
}
```