LINE is in Asia what Facebook Messaging and Instagram are to US mobile users -- a fast and easy way to communicate with friends and to discover new promotions about your favorite products and services. LINE is the number one mobile messaging platform in Japan and Taiwan and is also one of the largest Ads delivery platforms.

This TD export integration allows you to write job results from Treasure Data directly to a LINE Messaging account.

This topic includes:

What can you do with this Integration?

  • Export the user IDs or IFAs from Treasure Data to a LINE official account.


  • Basic Knowledge of Treasure Data

  • Basic knowledge LINE Messaging

  • LINE Messaging official account

Requirements and Limitations

  • Treasure Data does not verify the validity of your data; only null or empty data is filtered before uploading.

Use the TD Console to Create a Connection

In Treasure Data, you must create and configure the data connection prior to running your query. As part of the data connection, you provide authentication to access the integration.

Create a New Authentication

1. Open TD Console.
2. Navigate to Integrations Hub Catalog.
3. Search for LINE and select LINE Messaging.
4.  Select Create Authentication.
5. Type the Chanel Access Token to authenticate:
Chanel Access TokenLINE Messaging channel access token
6. Select Continue
7. Type a name for your connection.
8. Select Done.

Define your Query

1. Navigate to Data Workbench > Queries.
2. Select New Query.
3. Run the query to validate the result set.

Specify the Result Export Target

1.  Select Export Results.

2. You can select an existing authentication or create a new authentication for the external service to be used for output. Choose one of the following:

Use Existing Integration

Create a New Integration

Specify information for Export to LINE Messaging


Upload Audience by File.

Use existing LINE Audience ID to push an audienceUpload audiences to an Audience Group by specifying Audience ID instead of Audience Name.
Audience IDThe Audience Group ID.
Is IFAs Audience?

Select this checkbox if you are uploading IFA audiences, otherwise, LINE User ID is used.

Example Query

SELECT my_col as id FROM www_access

(Optional) Schedule Query Export Jobs

You can use Scheduled Jobs with Result Export to periodically write the output result to a target destination that you specify.

1. Navigate to Data Workbench > Queries.
2. Create a new query or select an existing query.
3. Next to Schedule, select None.

4. In the drop-down, select one of the following schedule options:

Drop-down ValueDescription
Custom cron...

Review Custom cron... details.

@daily (midnight)Run once a day at midnight (00:00 am) in the specified time zone.
@hourly (:00)Run every hour at 00 minutes.
NoneNo schedule.

Custom cron... Details

Cron Value


0 * * * *

Run once an hour.

0 0 * * *

Run once a day at midnight.

0 0 1 * *

Run once a month at midnight on the morning of the first day of the month.


Create a job that has no scheduled run time.

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

The following named entries can be used:

  • Day of Week: sun, mon, tue, wed, thu, fri, sat.

  • Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec.

A single space is required between each field. The values for each field can be composed of:

Field ValueExampleExample Description

A single value, within the limits displayed above for each field.

A wildcard ‘*’ to indicate no restriction based on the field. 

‘0 0 1 * *’ Configures the schedule to run at midnight (00:00) on the first day of each month.
A range ‘2-5’, indicating the range of accepted values for the field.‘0 0 1-10 * *’ Configures the schedule to run at midnight (00:00) on the first 10 days of each month.
A list of comma-separated values ‘2,3,4,5’, indicating the list of accepted values for the field.

0 0 1,11,21 * *’

Configures the schedule to run at midnight (00:00) every 1st, 11th, and 21st day of each month.
A periodicity indicator ‘*/5’ to express how often based on the field’s valid range of values a schedule is allowed to run.

‘30 */2 1 * *’

Configures the schedule to run on the 1st of every month, every 2 hours starting at 00:30. ‘0 0 */5 * *’ configures the schedule to run at midnight (00:00) every 5 days starting on the 5th of each month.
A comma-separated list of any of the above except the ‘*’ wildcard is also supported ‘2,*/5,8-10’‘0 0 5,*/10,25 * *’Configures the schedule to run at midnight (00:00) every 5th, 10th, 20th, and 25th day of each month.
5.  (Optional) You can delay the start time of a query by enabling the Delay execution.

Execute the Query

Save the query with a name and run, or just run the query. Upon successful completion of the query, the query result is automatically imported to the specified container destination.

Scheduled jobs that continuously fail due to configuration errors may be disabled on the system side after several notifications.

(Optional) Configure Export Results in Workflow

Within Treasure Workflow, you can specify the use of this data connector to export data.

Learn more at Using Workflows to Export Data with the TD Toolbelt.

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

(Optional) Export Integration Using the CLI

You can also use CLI(Toolbelt) for Result Export to LINE Messaging.

You need to specify the information for export to your LINE Messaging: server as `--result` option of `td query` command. Learn more about the `td query` command.

The format of the option is JSON and the general structure is as follows.

  "type": "line_messaging",
  "access_token": "xxxxx",
  "audience_name": "audience_name_abc",
  "use_audience_id": false,
  "is_ifa_audience": true


NameDescriptionValueDefault ValueRequired


Describe the name of the service as the destination of export.




The Channel access token



Audience Group name

Yes, if use_audience_id = false


Audience Group ID

Yes, use_audience_id = true


Use Audience Group ID instead of Name




Type of audience




Maximum number of retries when request failed




The initial amount of time before the first retry in seconds




The maximum amount of time to wait for a retry in seconds




The HTTP connection time out for a request to Pardot in seconds



Example for Usage 

$ td query --result '{"type":line_messaging", "access_token": "xxxxx", "use_audience_id": true, "audience_id": 1234567, "is_ifa_audience": true}' -d sample_datasets "select col1 as id from www_access" -T presto

  • No labels