# LINE Messaging エクスポート連携

LINEは、アジアにおいて、米国のモバイルユーザーにとってのFacebook MessagingやInstagramのような存在です。友人とのコミュニケーションや、お気に入りの製品やサービスに関する新しいプロモーションを発見するための、高速で簡単な手段です。LINEは日本と台湾で第1位のモバイルメッセージングプラットフォームであり、最大級の広告配信プラットフォームの1つでもあります。

このTDエクスポート連携により、Treasure Dataからジョブ結果を直接LINEメッセージングアカウントに書き込むことができます。

## この連携でできること

- Treasure DataからユーザーIDまたはIFAをLINEアカウントにエクスポートする。
- ユーザー、グループ、ルームに2つの方法でメッセージを送信:
  - Push Message - 単一のユーザーにメッセージを送信。
  - Multicast Message - 複数のユーザーにメッセージを送信。
- LINEメッセージへのメッセージ送信をサポート。10種類のタイプをサポート:
  - Text Message - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#text-message)
  - Text Message V2 - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#text-message-v2)
  - Sticker Message - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#sticker-message)
  - Image Message - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#image-message)
  - Video Message - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#video-message)
  - Audio Message - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#audio-message)
  - Location Message - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#location-message)
  - Image Map Message - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#imagemap-message)
  - Template Messages - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#template-messages)
  - Flex Message - [Messaging API reference](https://developers.line.biz/en/reference/messaging-api/#flex-message)


## 前提条件

- Treasure Dataの基本知識
- LINEメッセージングの基本知識
- 公式LINEメッセージングアカウント


## 要件と制限事項

- Treasure Dataはデータの有効性を検証しません。Treasure Dataはアップロード前にNULLまたは空のデータのみをフィルタリングします。


## Treasure コンソールを使用した連携の作成

データをエクスポートするクエリを実行する前に、Treasure コンソールでデータ連携を作成および設定する必要があります。データ連携の一部として、連携にアクセスするための認証資格情報を提供します。

LINEは2つの認証方法をサポートしています:

- Channel Access Token (デフォルト)
- Short-Lived Token


### 新しいChannel Access Token認証の作成

1. **Treasure コンソール**を開きます。
2. **Integrations Hub** > **Catalog**に移動します。
3. LINEを検索し、**LINE Messaging**を選択します。
4. **Create Authentication**を選択します。
5. Authentication Methodドロップダウンから、**Channel Access Token**を選択します。
6. LINEアカウントへの認証に使用されるLINE MessagingのChannel Access Tokenを入力します。
7. **Continue**を選択します。
8. 連携の名前を入力します。
9. **Done**を選択します。


### 新しいShort-Lived Token認証の作成

1. **Treasure コンソール**を開きます。
2. **Integrations Hub** > **Catalog**に移動します。
3. LINEを検索し、**LINE Messaging**を選択します。
4. **Create Authentication**を選択します。
5. Authentication Methodドロップダウンから、**Short Lived Token**を選択します。
6. LINE Messaging Channel Id**を入力します。**
7. Channel Secret**を入力します。**
8. **Continue**を選択します。
9. 連携の名前を入力します。
10. **Done**を選択します。


### クエリの定義

1. **Data Workbench > Queries**に移動します。
2. **New Query**を選択します。
3. databaseドロップダウンで、クエリしたいデータベースを入力します。この例では*test_db*を使用します。
4. クエリペインで、SQLクエリを入力します。
5. **Run**を選択してクエリの結果を検証します。


**ターゲット: Audience**

![](/assets/download.216de0cc895950d0abe8b9a594e3cce72ec76b511b768033c04778225233f22d.77d44e6e.png)

**ターゲット: Push Message**

![](/assets/screenshot-2025-06-19-at-15.42.47.7c3a771716f61060116ebadcb17909da5db020574ea01060f46be4435a4c2071.77d44e6e.png)

**ターゲット: Multicast Message**

![](/assets/screenshot-2025-06-19-at-15.43.07.adaf0ae2ea00103777f7f12a18805b30b32a63c48e977fe59c46a5e797cc34cf.77d44e6e.png)

**注意:**

- Push MessageとMulticast Messageの2つのターゲットでは、受信者IDをスキーマで定義する必要があります。
- Push Messageターゲットは、Template Message内でプレースホルダーをサポートします。
  - プレースホルダーは{{ ... }}内に含まれる変数であり、スキーマで完全に定義する必要があります。各レコードの対応する値で置き換えられます。
- Push MessageターゲットのTemplate Messageの例。



```json
{
  "type": "textV2",
  "text": "Welcome, {user1}! {laugh}\n {everyone} There is a newcomer!",
  "substitution": {
    "user1": {
      "type": "mention",
      "mentionee": {
        "type": "user",
        "userId": "{{user_1_id}}"
      }
    },
    "laugh": {
      "type": "emoji",
      "productId": "{{product_id}}",
      "emojiId": "{{emoji_id}}"
    },
    "everyone": {
      "type": "mention",
      "mentionee": {
        "type": "all"
      }
    }
  }
}
```

- Multicast Messageを使用する場合は、受信者IDカラムのみを定義する必要があります。


### 結果のエクスポート先の指定

1. **Export Results**を選択します。


![](/assets/queries-untitled-query-treasure-data-3.6cb768236972ecbf96e74f2154224779ce0010e2e6f31f183b44fcb233f83720.77d44e6e.png)

1. 外部サービスに結果をエクスポートするには、既存の認証を使用するか、新しい認証を作成します。次のいずれかを選択します。


- Use Existing Integration
- Create New Integration


**Use Existing Integration**

1. **Use Existing Integration**を選択します。
2. 使用したい既存の連携を選択します。この例では*line_messaging_output_test*を使用します。
![](/assets/existingintegration.d3db20e3d73c18db4bf5fddaa7b0973b6b684c3012051d6608d13b2a3ba44f6a.77d44e6e.png)
3. フォームに情報を入力します。


![](/assets/screenshot-2025-06-18-at-14.53.15.b01903739fd069b840b8a4d419e897a0b192e7172b36881fcc092f56da4ff2d0.77d44e6e.png)
![](/assets/screenshot-2025-06-18-at-14.53.22.04f1b463e338743ea4de772a24f45af852327f4985e82dfd9ee92b6171cefdc2.77d44e6e.png)
![](/assets/screenshot-2025-06-18-at-14.53.32.38861e77a89f83a8c7f8f0b5314b36bd0be4126807a22c4a718a5775c1a5d1e0.77d44e6e.png)
4. **Done**を選択します。

| フィールド | 説明 |
|  --- | --- |
| Target | データをアップロードする必要があるLINE Messageオブジェクト。サポートされるオブジェクト:   - Audience - Push Message - Multicast Message |
| Use existing LINE Audience ID to push an audience | Audience NameではなくAudience IDを指定してオーディエンスをAudience Groupにアップロードします。 |
| Audience Name | Audience Nameを指定してオーディエンスをAudience Groupにアップロードします。 |
| Is IFAs Audience? | IFAオーディエンスをアップロードする場合は、このチェックボックスを選択します。それ以外の場合は、LINE User IDが使用されます。 |
| Template Message | テキストメッセージの入力エリア。 |
| Skip Invalid Message | 無効なメッセージをスキップし、有効なメッセージのみを送信する場合に有効にします。無効にした場合、無効なメッセージがあるとエラーメッセージが表示されます。 |
| Notification Disabled | サイレントでメッセージを送信する場合に有効にします。(デフォルト=False) |
| Custom Aggregation Units | 集計単位の名前。大文字と小文字が区別されます。例えば、Promotion_aとPromotion_Aは異なる単位名として扱われます。  - 最大単位数: 1 - 最大文字数: 30 - サポートされる文字タイプ: 半角英数字 (a-z, A-Z, 0-9) およびアンダースコア (_) |


**新しいIntegrationを作成する**

1. **Create New Integration**を選択します。
2. Typeドロップダウンから**LINE Messaging**を選択します。
3. 新しいintegrationの名前を入力します。
4. Authentication Methodドロップダウンから**Channel Access Token**または**Short Lived Token**を選択します。
5. フォームに残りの情報を入力します。


![](/assets/linenewint.6e02e8ed8b764824515fcdb9bafdd091c4de25ff34e81b86e5f7651cd6ce7a1c.77d44e6e.png)
6. **Next**を選択します。
7. Export Resultsフォームに情報を入力します。
8. **Done**を選択します。

| フィールド | 説明 |
|  --- | --- |
| Name | このIntegrationの名前。 |
| Channel Access Token | LINEチャネルアクセストークンまたは永続的に有効な長期トークン。 |
| Chanel Id | LINEチャネルID (短期トークン認証用)。 |
| Channel Secret | LINEチャネルシークレット (短期トークン認証用) |
| Maximum Retry | システムが諦めるまでの再試行回数。デフォルト: 7 |
| Seconds to Wait For First Retry | 最初と2回目の試行の間の時間 (秒単位)。デフォルト: 15 |
| Seconds for Max Retry Wait | 2回目以降のすべての試行の間の時間 (秒単位)。デフォルト: 3600 |
| Seconds for Connection Timeout | HTTP呼び出し操作が中止されるまでの待機時間 (秒単位)。デフォルトは300 |
| Use existing LINE Audience ID to push an audience | Audience NameではなくAudience IDを指定してオーディエンスをAudience Groupにアップロードします。 |
| Audience Name | Audience Nameを指定してオーディエンスをAudience Groupにアップロードします。 |
| Is IFAs Audience? | IFAオーディエンスをアップロードする場合は、このチェックボックスを選択します。それ以外の場合は、LINE User IDが使用されます。 |


### Example Query


```sql
SELECT my_col as id FROM www_access
```

### (オプション) Query Export ジョブをスケジュールする

Scheduled Jobs と Result Export を使用して、指定したターゲット宛先に出力結果を定期的に書き込むことができます。

Treasure Data のスケジューラー機能は、高可用性を実現するために定期的なクエリ実行をサポートしています。

2 つの仕様が競合するスケジュール仕様を提供する場合、より頻繁に実行するよう要求する仕様が優先され、もう一方のスケジュール仕様は無視されます。

例えば、cron スケジュールが `'0 0 1 * 1'` の場合、「月の日」の仕様と「週の曜日」が矛盾します。前者の仕様は毎月 1 日の午前 0 時 (00:00) に実行することを要求し、後者の仕様は毎週月曜日の午前 0 時 (00:00) に実行することを要求するためです。後者の仕様が優先されます。

#### Treasure コンソール を使用してジョブをスケジュールする

1. **Data Workbench > Queries** に移動します
2. 新しいクエリを作成するか、既存のクエリを選択します。
3. **Schedule** の横にある None を選択します。
![](/assets/image2021-1-15_17-28-51.f1b242f6ecc7666a0097fdf37edd1682786ec11ef80eff68c66f091bc405c371.0f87d8d4.png)
4. ドロップダウンで、次のスケジュールオプションのいずれかを選択します:
![](/assets/image2021-1-15_17-29-47.45289a1c99256f125f4d887e501e204ed61f02223fde0927af5f425a89ace0c0.0f87d8d4.png)
| ドロップダウン値 | 説明 |
|  --- | --- |
| Custom cron... | [Custom cron... の詳細](#custom-cron-details)を参照してください。 |
| @daily (midnight) | 指定されたタイムゾーンで 1 日 1 回午前 0 時 (00:00 am) に実行します。 |
| @hourly (:00) | 毎時 00 分に実行します。 |
| None | スケジュールなし。 |


#### Custom cron... の詳細

![](/assets/image2021-1-15_17-30-23.0f94a8aa5f75ea03e3fec0c25b0640cd59ee48d1804a83701e5f2372deae466c.0f87d8d4.png)

| **Cron 値** | **説明** |
|  --- | --- |
| `0 * * * *` | 1 時間に 1 回実行します。 |
| `0 0 * * *` | 1 日 1 回午前 0 時に実行します。 |
| `0 0 1 * *` | 毎月 1 日の午前 0 時に 1 回実行します。 |
| "" | スケジュールされた実行時刻のないジョブを作成します。 |



```
 *    *    *    *    *
 -    -    -    -    -
 |    |    |    |    |
 |    |    |    |    +----- day of week (0 - 6) (Sunday=0)
 |    |    |    +---------- month (1 - 12)
 |    |    +--------------- day of month (1 - 31)
 |    +-------------------- hour (0 - 23)
 +------------------------- min (0 - 59)
```

次の名前付きエントリを使用できます:

- Day of Week: sun, mon, tue, wed, thu, fri, sat.
- Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec.


各フィールド間には単一のスペースが必要です。各フィールドの値は、次のもので構成できます:

div
| フィールド値  | 例  | 例の説明  |
|  --- | --- | --- |
| 各フィールドに対して上記で表示された制限内の単一の値。 |  |  |
| フィールドに基づく制限がないことを示すワイルドカード
`'*'`。 | `'0 0 1 * *'` | 毎月 1 日の午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |
| 範囲 `'2-5'`
フィールドの許可される値の範囲を示します。 | `'0 0 1-10 * *'` | 毎月 1 日から 10 日までの午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |
| カンマ区切りの値のリスト `'2,3,4,5'`
フィールドの許可される値のリストを示します。 | `0 0 1,11,21 * *'` | 毎月 1 日、11 日、21 日の午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |
| 周期性インジケータ `'*/5'`
フィールドの有効な値の範囲に基づいて、
スケジュールが実行を許可される頻度を表現します。 | `'30 */2 1 * *'` | 毎月 1 日、00:30 から 2 時間ごとに実行するようにスケジュールを設定します。
`'0 0 */5 * *'` は、毎月 5 日から 5 日ごとに午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |
| `'*'`
ワイルドカードを除く上記の
いずれかのカンマ区切りリストもサポートされています
`'2,*/5,8-10'` | `'0 0 5,*/10,25 * *'` | 毎月 5 日、10 日、20 日、25 日の午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |


1. (オプション) Delay execution を有効にすることで、クエリの開始時刻を遅延させることができます。


### クエリを実行する

クエリに名前を付けて保存して実行するか、単にクエリを実行します。クエリが正常に完了すると、クエリ結果は指定された宛先に自動的にエクスポートされます。

設定エラーにより継続的に失敗するスケジュールジョブは、複数回通知された後、システム側で無効化される場合があります。

(オプション) Delay execution を有効にすることで、クエリの開始時刻を遅延させることができます。

## Audience Studio で Segment をアクティベートする

Audience Studio で activation を作成することで、segment データをターゲットプラットフォームに送信することもできます。

1. **Audience Studio** に移動します。
2. parent segment を選択します。
3. ターゲット segment を開き、右クリックして、**Create Activation** を選択します。
4. **Details** パネルで、Activation 名を入力し、前述の Configuration Parameters のセクションに従って activation を設定します。
5. **Output Mapping** パネルで activation 出力をカスタマイズします。


![](/assets/ouput.b2c7f1d909c4f98ed10f5300df858a4b19f71a3b0834df952f5fb24018a5ea78.8ebdf569.png)

- Attribute Columns
  - **Export All Columns** を選択すると、変更を加えずにすべての列をエクスポートできます。
  - **+ Add Columns** を選択して、エクスポート用の特定の列を追加します。Output Column Name には、Source 列名と同じ名前があらかじめ入力されます。Output Column Name を更新できます。**+ Add Columns** を選択し続けて、activation 出力用の新しい列を追加します。
- String Builder
  - **+ Add string** を選択して、エクスポート用の文字列を作成します。次の値から選択します:
    - String: 任意の値を選択します。テキストを使用してカスタム値を作成します。
    - Timestamp: エクスポートの日時。
    - Segment Id: segment ID 番号。
    - Segment Name: segment 名。
    - Audience Id: parent segment 番号。


1. **Schedule** を設定します。


![](/assets/snippet-output-connector-on-audience-studio-2024-08-28.a99525173709da1eb537f839019fa7876ffae95045154c8f2941b030022f792c.8ebdf569.png)

- スケジュールを定義する値を選択し、オプションでメール通知を含めます。


1. **Create** を選択します。


batch journey の activation を作成する必要がある場合は、[Creating a Batch Journey Activation](/products/customer-data-platform/journey-orchestration/batch/creating-a-batch-journey-activation) を参照してください。

## (オプション) WorkflowでExport Resultsを設定する

Treasure ワークフロー内で、このデータコネクタを使用してデータをエクスポートするように指定できます。

[ワークフローを使用してデータをエクスポートする方法](/tools/cli-and-sdks/api#workflow-commands)[とTD Toolbelt](/tools/cli-and-sdks/api#workflow-commands)の詳細をご覧ください。


```yaml
_export:
  td:
  database: td.database

+line_messaging_export_task:
  td>: export_line_messaging.sql
  database: ${td.database}
  result_connection: {your_connection_name}
  result_settings:
    audience_name: audience_name_abc
  	use_audience_id: false
  	is_ifa_audience: true
```

## (オプション) CLIを使用したExport Integration

TD Toolbeltが提供するCLIを使用して、クエリ結果をLINE messagingにエクスポートすることもできます。

td queryコマンドを使用する場合、--result RESULT_URLオプションでLINE messagingサーバーのURLを指定します。詳細については、[td query](/tools/cli-and-sdks/api#td-query)を参照してください。

オプションの形式はJSONで、一般的な構造は以下の通りです。

または

**パラメータ**

| Name | Description | Value | Default Value | Required |
|  --- | --- | --- | --- | --- |
| type | エクスポート先のサービス名を記述します。 | line_messaging |  | Yes |
| auth_method | 認証方法は、長期トークンまたは期限付きトークンのいずれかを指定できます。 | `channel_access_token`  `short_lived_token` | channel_access_token | Yes |
| access_token | Channel access token。 |  |  | Yes, if auth_method=channel_access_token |
| client_id | LINE Client ID。 |  |  | Yes, if auth_method=short_lived_token |
| client_secret | LINE Client Secret。 |  |  | Yes, if auth_method=short_lived_token |
| target | データをアップロードする必要があるLINE Messageオブジェクト。 | - audience - push_message - multicast_message | audience | Yes |
| audience_name | Audience Group名。 |  |  | Yes, if use_audience_id = false |
| audience_id | Audience Group ID。 |  |  | Yes, if use_audience_id = true |
| use_audience_id | Audience Group Nameの代わりにIDを使用します。 |  | false | No |
| is_ifa_audience | オーディエンスのタイプ。 |  | true | No |
| template_message | プッシュするテンプレートメッセージ。メッセージをカスタマイズするためのplace_holderをサポートします。 | String |  | Yes, if target = push_message |
| template_message_multicast | マルチキャストするテンプレートメッセージ。place_holderはサポートしていません。 | String |  | Yes, if target = template_message_multicast |
| skip_invalid_message | Push Messageの無効なメッセージをスキップします。 | Boolean | true | No |
| skip_multicast_invalid_message | Multicast Messageの無効なメッセージをスキップします。 | Boolean | true | No |
| notification_disabled | マルチキャストメッセージ送信時の通知を無効にします。 | Boolean | true | No |
| custom_aggregation_units | マルチキャストメッセージのカスタム集計単位。 | String |  | No |
| batch_size_multicast | マルチキャストメッセージのバッチサイズ。 | Integer  1から500の間である必要があります  デフォルト: 10 | 10 | No |
| max_retry | リクエストが失敗した場合の最大再試行回数 |  | 8 | No |
| initial_retry_wait | 最初の再試行前の初期待機時間 (秒単位) |  | 15 | No |
| max_retry_wait | 再試行の最大待機時間 (秒単位) |  | 3600 | No |
| connection_timeout | Pardotへのリクエストに対するHTTP接続タイムアウト (秒単位) |  | 300 | No |


### Example for Usage

**Channel Access Tokenによる認証**


```
out:
  type: line_messaging
  access_token: xxxx
  auth_method: channel_access_token
  ...
```

**Short Lived Tokenによる認証**


```
out:
  type: line_messaging
  client_id: 1234
  client_secret: xxxx
  auth_method: short_lived_token  ...
```

**Upload Audience**


```yaml
out:
   type: line_messaging
   access_token: xxxx
   auth_method: channel_access_token
   target: audience
   audience_name: test group
   use_audience_id: true
  audience_id: 33948315694
  is_ifa_audience: true
```

**プッシュメッセージの送信**


```yaml
out:
  type: line_messaging
  access_token: xxxx
  auth_method: channel_access_token
  target: push_message
  template_message: |
    {
      "type": "textV2",
      "text": "Welcome, {user1}! {laugh}\n{everyone} There is a newcomer!",
      "substitution": {
          "user1": {
          "type": "mention",
          "mentionee": {
              "type": "user",
              "userId": "{{user_1_id}}"
          }
          },
          "laugh": {
              "type": "emoji",
              "productId": "{{emoji_product_id}}",
              "emojiId": "{{emoji_id}}"
          },
          "everyone": {
              "type": "mention",
              "mentionee": {
                  "type": "all"
          }
          }
      }
    }
  skip_invalid_message: true
```

**マルチキャストメッセージの送信**


```yaml
out:
  type: line_messaging
  target: multicast_message
  access_token: xxxx
  auth_method: channel_access_token
  template_message_multicast: |
    {
      "type": "textV2",
      "text": "Hi, new friend ! {laugh}",
      "substitution": {
          "laugh": {
              "type": "emoji",
              "productId": "670e0cce840a8236ddd4ee4c",
              "emojiId": "006"
          }
          }
      }
    }
  skip_multicast_invalid_message: true
```

# テンプレートメッセージの例

1. テキストメッセージ - [Messaging APIリファレンス](https://developers.line.biz/en/reference/messaging-api/#text-message)



```json
{
   "type": "text",
   "text": "Hello, world"
}
```

​
2. テキストメッセージV2 - [Messaging APIリファレンス](https://developers.line.biz/en/reference/messaging-api/#text-message-v2)


```json
{
  "type": "textV2",
  "text": "Welcome, {user1}! {laugh}\n{everyone} There is a newcomer!",
  "substitution": {
    "user1": {
      "type": "mention",
      "mentionee": {
        "type": "user",
        "userId": "U49585cd0d5..."
      }
    },
    "laugh": {
      "type": "emoji",
      "productId": "5a8555cfe6256cc92ea23c2a",
      "emojiId": "002"
    },
    "everyone": {
      "type": "mention",
      "mentionee": {
        "type": "all"
      }
    }
  }
}
```

1. スティッカーメッセージ - [Messaging APIリファレンス](https://developers.line.biz/en/reference/messaging-api/#sticker-message)



```json
{
  "type": "sticker",
  "packageId": "446",
  "stickerId": "1988"
}
```

1. 画像メッセージ - [Messaging APIリファレンス](https://developers.line.biz/en/reference/messaging-api/#image-message)



```json
{
  "type": "image",
  "originalContentUrl": "https://example.com/original.jpg",
  "previewImageUrl": "https://example.com/preview.jpg"
}
```

1. 動画メッセージ - [Messaging APIリファレンス](https://developers.line.biz/en/reference/messaging-api/#video-message)



```json
{
  "type": "video",
  "originalContentUrl": "https://example.com/original.mp4",
  "previewImageUrl": "https://example.com/preview.jpg",
  "trackingId": "track-id"
}
```

1. 音声メッセージ - [Messaging APIリファレンス](https://developers.line.biz/en/reference/messaging-api/#audio-message)



```json
{
  "type": "audio",
  "originalContentUrl": "https://example.com/original.m4a",
  "duration": 60000
}
```

1. 位置情報メッセージ - [Messaging APIリファレンス](https://developers.line.biz/en/reference/messaging-api/#location-message)



```json
{
{
  "type": "location",
  "title": "my location",
  "address": "1-3 Kioicho, Chiyoda-ku, Tokyo, 102-8282, Japan",
  "latitude": 35.67966,
  "longitude": 139.73669
}
```

1. Imagemap Message - [Messaging API リファレンス](https://developers.line.biz/en/reference/messaging-api/#imagemap-message)



```json
{
  "type": "imagemap",
  "baseUrl": "https://example.com/bot/images/rm001",
  "altText": "This is an imagemap",
  "baseSize": {
    "width": 1040,
    "height": 1040
  },
  "video": {
    "originalContentUrl": "https://example.com/video.mp4",
    "previewImageUrl": "https://example.com/video_preview.jpg",
    "area": {
      "x": 0,
      "y": 0,
      "width": 1040,
      "height": 585
    },
    "externalLink": {
      "linkUri": "https://example.com/see_more.html",
      "label": "See More"
    }
  },
  "actions": [
    {
      "type": "uri",
      "linkUri": "https://example.com/",
      "area": {
        "x": 0,
        "y": 586,
        "width": 520,
        "height": 454
      }
    },
    {
      "type": "message",
      "text": "Hello",
      "area": {
        "x": 520,
        "y": 586,
        "width": 520,
        "height": 454
      }
    }
  ]
}
```

1. Template Messages - [Messaging API リファレンス](https://developers.line.biz/en/reference/messaging-api/#template-messages)



```json
{
  "type": "template",
  "altText": "This is a buttons template",
  "template": {
    "type": "buttons",
    "thumbnailImageUrl": "https://example.com/bot/images/image.jpg",
    "imageAspectRatio": "rectangle",
    "imageSize": "cover",
    "imageBackgroundColor": "#FFFFFF",
    "title": "Menu",
    "text": "Please select",
    "defaultAction": {
      "type": "uri",
      "label": "View detail",
      "uri": "http://example.com/page/123"
    },
    "actions": [
      {
        "type": "postback",
        "label": "Buy",
        "data": "action=buy&itemid=123"
      },
      {
        "type": "postback",
        "label": "Add to cart",
        "data": "action=add&itemid=123"
      },
      {
        "type": "uri",
        "label": "View detail",
        "uri": "http://example.com/page/123"
      }
    ]
  }
}
```

1. Flex Message - [Messaging API リファレンス](https://developers.line.biz/en/reference/messaging-api/#flex-message)



```json
{
  "type": "flex",
  "altText": "this is a flex message",
  "contents": {
    "type": "bubble",
    "body": {
      "type": "box",
      "layout": "vertical",
      "contents": [
        {
          "type": "text",
          "text": "hello"
        },
        {
          "type": "text",
          "text": "world"
        }
      ]
    }
  }
}
```

## 付録 A: LINE Channel ID と Channel secret の取得方法

1. [https://developers.line.biz/en/](https://developers.line.biz/en/) にアクセスし、右上の **login** を選択します。


![](/assets/linelogin.b40e0916e82ff28ee04c06b07ed3cf66bf8f93aeffa1dbec4d081a9a5df3efe3.77d44e6e.png)

1. **Log in with LINE account** を選択します。


![](/assets/linebizacct.3dfeff8c0d2712ea14ac4c864d24f0792068833afe2b91bd6e3f51b43301def2.77d44e6e.png)

1. LINE 公式アカウントのユーザー名とパスワードを入力し、**Log in** を選択します。


![](/assets/loginpsswd.9c7e96beea924c6e3a3d7ad252690a733b7065b12ca64bdf878c044a7f721a34.77d44e6e.png)

1. チャネルにアクセスします


![](/assets/image2022-11-3_15-32-32.76df41c1cc5ade8517c0bc5c7576755c77375d7118bbc66f0bc8b9dfe3d2de65.77d44e6e.png)

1. チャネルで **Basic settings** タブを選択します。


このタブに **Channel ID** と **Channel secret** が表示されます。

![](/assets/image2022-11-3_16-10-45.88a077e14236f74c4f6b89f380de298629c8c28ab6a90626bb2725ff736e2e7c.77d44e6e.png)