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 Taiwan. It is also one of the largest mobile messaging platforms in Japan and Thailand. Through Crescendo Labs MAAC API, we are developing an out-of-the-box integration to activate LINE. This integration allows you to authenticate using the API token, upload members with tags, and create and update segments with Line UIDs. 


This article contains

Prerequisites

  • Basic Knowledge of Treasure Data.

  • Basic knowledge of MAAC Crescendo Experience Account

Requirements and Limitations

The Connector implements minimal data validation, you must make sure your data is valid Line/Crescendo Lab spec to avoid job fail. For example, line_uid, email, mobile must be valid Line's data, birthday must be valid ISO format e.g. 1985-04-06.

Use the TD Console to Create Your Connection

Create a New 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.

1. Open TD Console.
2. Navigate to Integrations Hub Catalog.
3. Search for and select Line via Crescendo.

4. Select Create Authentication.
5. Type the credentials to authenticate.

6. Type a name for your connection.
7. Select Done.



Define your Query

Depend on the Data Object you've chosen, the supporting columns will be different.

Data Object: Members

ColumnData TypeRequiredDescription
line_uidstringYes (if import key is line_uid)The unique user ID of the member in the LINE official account
line_display_namestringNoThe name defined by the member in the official LINE account
emailstringYes (if import key is email)Member email address
mobilestringYes (if import key is mobile)Member phone number
customer_idstringYes (if import key is customer_id)User ID of the third-party system
genderstringNoThe gender of the member (default is predicted by MAAC AI)
male: male
female: female
birthdaystringNoMember's birthday (ISO Format) E.g. 2000-02-23
tagscomma-separated stringsNotags to tag to individual members

Data Object: Segments

ColumnData TypeRequiredDescription
line_uidstringYesLine UID to be imported


  1. Complete the instructions in Creating a Destination Integration.
  2. Navigate to Data Workbench > Queries.

  3. Select a query for which you would like to export data.

  4. Run the query to validate the result set.

  5. Select Export Results.

  6. Select an existing integration authentication.
  7. Define any additional Export Results details. In your export integration content review the integration parameters.
    For example, your Export Results screen might be different, or you might not have additional details to fill out:
  8. Select Done.

  9. Run your query.

  10. Validate that your data moved to the destination you specified.


Integration Parameters for Line via Crescendo Lab

ParametertypeRequiredDescription
Access Token (api_token)StringYesAccess token
Data Object (data_object)

StringYesMembers (members) or Segments (segments)
Import Key (import_key)StringYes (if Data Object is Members)

Value: line_uidcustomer_idemail, or mobile

Tags (tags)StringYesComma-separated strings of tags
Segment Name (segment_name)StringYes (if Data Object is Segments)Segment name
Description (segment_description)StringNoSegment description
Skip Invalid Records (skip_invalid_records)BooleanNoSkip invalid records and continue the job (default: true)
update_segment)BooleanNoUpdate existing segment

Example Query

SELECT 
  line_uid,
  customer_id,
  display_name,
  gender,
  email,
  tags,
  birthday
FROM
  line_members

Optionally Schedule the 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

Description

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) If you enabled the Delay execution, you can delay the start time of a query.

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.


Optionally Configure Export Results in Workflow

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

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

Example Workflow for Line via Crescendo


timezone: UTC
 
_export:
  td:
    database: sample_datasets
 
+td-result-into-line:
  td>: queries/sample.sql
  result_connection: your_connection_name
  result_settings:
    api_token: ###
    data_object: members
    import_key: line_uid
    tags: import210707, apple product interested
  • No labels