

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

# CreateWhatsAppMessageTemplate API を使用したメッセージテンプレートの作成
<a name="create-message-templates-api"></a>

API を使用して、カスタマイズされた WhatsApp メッセージテンプレートを作成できます。このトピックでは、[CreateWhatsAppMessageTemplate](https://docs.aws.amazon.com/social-messaging/latest/APIReference/API_CreateWhatsAppMessageTemplate.html) を使用してさまざまなメッセージテンプレートを作成する方法について説明します。

## メッセージテンプレートコンポーネント
<a name="message-template-components"></a>

 メッセージテンプレートには、次のコンポーネントを含めることができます。
+ **ヘッダー**: 上部に表示されるタイトルテキスト
+ **本文**: 可変プレースホルダーを含むメインメッセージコンテンツ
+ **フッター**: 下部の追加情報
+ **ボタン**: URLs にリンクするクリック可能な要素

次の例では、{{ENDPOINT}} と {{WABA\_ID}} を実際のエンドポイント URL と ID に置き換えます。

## 基本的な英語ユーティリティテンプレートを作成する
<a name="simple-body-only-utility-template"></a>

この例では、 `BODY`コンポーネントのみを使用し、`HEADER`、、`FOOTER`または `BUTTON`コンポーネントを含まないユーティリティメッセージテンプレートを英語で作成します。本文テキストは可変プレースホルダーを使用します。

```
$ aws socialmessaging create-whatsapp-message-template --region {{us-east-1}} --endpoint-url {{ENDPOINT_URL}} \ 
--id {{WABA_ID}} \ 
--template-definition '{
    "name": "order_update_basic",
    "language": "en_US",
    "allow_category_change": true,
    "category": "UTILITY",
    "components": [
        {
            "type": "BODY",
            "text": "Hi {{1}}, your order #{{2}} has been shipped. Track your delivery below."
        }
    ]
}'
```

## ボタンを使用して基本的な英語ユーティリティテンプレートを作成する
<a name="utility-template-with-button-example"></a>

この例では、 `BODY` および `BUTTON`コンポーネントを含むユーティリティメッセージテンプレートを英語で作成します。

```
$ aws socialmessaging create-whatsapp-message-template --region {{us-east-1}} --endpoint-url {{ENDPOINT_URL}} \
--id {{WABA_ID}} \
--template-definition '{
    "name": "order_update_with_button",
    "language": "en_US",
    "allow_category_change": true,
    "category": "UTILITY",
    "components": [
        {
            "type": "BODY",
            "text": "Hi {{1}}, your order #{{2}} has been shipped. Track your delivery below."
        },
        {
            "type": "BUTTONS",
            "buttons": [
                {
                    "type": "URL",
                    "text": "Track Order",
                    "url": "https://example.com/track"
                }
            ]
        }
    ]
}'
```

## ヘッダー、本文、ボタンを使用して複雑な英語ユーティリティメッセージテンプレートを作成する
<a name="utility-template-button-header"></a>

この例では、`HEADER`、`BODY`、 `BUTTON`コンポーネントを含むユーティリティメッセージテンプレートを英語で作成します。

```
$ aws socialmessaging create-whatsapp-message-template --region {{us-east-1}} --endpoint-url {{ENDPOINT_URL}} \
--id {{WABA_ID}} \
--template-definition '{
  "name": "account_creation_confirmation_3333",
  "category": "UTILITY",
  "language": "en_US",
  "status": "APPROVED",
  "components": [
    {
      "type": "HEADER",
      "format": "TEXT",
      "text": "Finalize account set-up"
    },
    {
      "type": "BODY",
      "text": "Hi {{1}},\n\nYour new account has been created successfully. \n\nPlease verify {{2}} to complete your profile.",
      "example": {
        "body_text": [
          [
            "John",
            "your email address"
          ]
        ]
      }
    },
    {
      "type": "BUTTONS",
      "buttons": [
        {
          "type": "URL",
          "text": "Verify account",
          "url": "https://www.example.com/"
        }
      ]
    }
  ]
}'
```

## 基本的なマーケティングメッセージテンプレートを作成する
<a name="simple-marketing-template"></a>

この例では、`BODY`コンポーネントのみを含む基本的なマーケティングメッセージテンプレートを作成します。

```
$ aws socialmessaging create-whatsapp-message-template --region us-east-1 --endpoint-url {{ENDPOINT_URL}} \
--id {{WABA_ID}} \ 
--template-definition '{
  "id": "1290345849293233",
  "name": "holiday_special_1395238",
  "category": "MARKETING",
  "language": "en_US",
  "status": "PENDING",
  "components": [
    {
      "type": "BODY",
      "text": "Season's Greetings {{1}}!\n\nCelebrate {{2}} with amazing deals up to {{3}} off.\n\nPlus, get free gift wrapping on all orders above $50.",
      "example": {
        "body_text": [
          [
            "Pawan",
            "Christmas",
            "30%"
          ]
        ]
      }
    }
  ],
  "metaTemplateId": "1290345849293233"
}'
```

## 複雑なマーケティングメッセージテンプレートを作成する
<a name="full-marketing-template"></a>

この例では、`HEADER`、`BODY`、 `BUTTON`コンポーネントを含むマーケティングメッセージテンプレートを英語で作成します。

```
$ aws socialmessaging create-whatsapp-message-template --region us-east-1 \
--endpoint-url {{ENDPOINT_URL}} \ 
--id {{WABA_ID}} \
--template-definition '{
  "name": "summer_sale_1",
  "category": "MARKETING",
  "language": "en_US",
  "status": "APPROVED",
  "components": [
    {
      "type": "HEADER",
      "format": "TEXT",
      "text": "Summer Sale!"
    },
    {
      "type": "BODY",
      "text": "Hi {{1}}! Get {{2}} off all summer items. Shop now before stock runs out!"
    },
    {
      "type": "FOOTER",
      "text": "Valid until August 31st"
    },
    {
      "type": "BUTTONS",
      "buttons": [
        {
          "type": "URL",
          "text": "Shop Now",
          "url": "https://example.com/sale"
        }
      ]
    }
  ]
}'
```