LINE Messaging overview

Learn how to send LINE messages using our LINE Messaging integration.

Overview

Use our LINE integration to enable the LINE node in automation programs, which can be used to send LINE messages to opted in customers.

The LINE Integration is currently only available as a private preview; please contact your Customer Success Manager if you are interested in using this integration.

Before you start

Things you need to know:

  • You must have a LINE Business account.
    You can register for LINE through your app. 
  • Can log into the LINE Developers Console.
  • Have a LINE for Business messaging rate plan.
    You are limited to 1000 messages per month without a rate plan by LINE.
  • Have a LINE provider registered in the LINE Developer Console you want to use with Dotdigital with the Messaging API channel enabled, instructions on how to do this can be found here.
    We will need to remap the webhook to point at Dotdigital’s services and therefore it shouldn’t be in use with any other service

Configuring LINE
Step 1: Complete the settings for the LINE integration

Dotdigital will have created an instance of the LINE integration in your Dotdigital account, complete the settings in order to activate it.

To complete your LINE integration settings:

  1. Go to the Integration hub.
  2. Select the Active tab.
  3. Find and select the LINE tile.
  4. Select Setup to complete the setup
  5. You will be presented with a brief summary of functionality and a warning about the webhook for the LINE provider being overwritten during the setup; if you are happy to proceed select Ok.
    If you do not want to continue, select Cancel.

line-message-integration.png

Step 2: Configure your LINE Messaging API authorization

To allow Dotdigital to call the LINE Messaging API you need to enter the authorization details.

  1. Enter your LINE Providers’ LINE Channel access token, this can be found in the LINE Developers Console in the providers settings found described below:
    1. Enter your LINE providers settings.
    2. Select the Messaging API tab.
    3. Go to the bottom of the tab settings and you will see the Channel access token (long-lived) field.
    4. If a value is shown, copy the value and enter it in the settings, otherwise select Issue to create a new token.
  2. Enter your LINE Providers’ LINE Channel secret which can be found in the LINE Developers Console in the providers settings found described below:
    1. Enter your LINE providers settings.
    2. Select the Basic settings tab.
    3. Go to the bottom of the tab settings and you will see the Channel secret field, copy the value and enter it in the settings.
  3. Select Next, the details entered will be checked and your LINE Providers webhook will be configured to send data to Dotdigital.

Step 3: Configure the opt in journey

To allow Dotdigital to link a LINE user to a Dotdigital contact, we will automatically ask new LINE users that follow or message your LINE Provider for their email address in order to proceed. You can customise the messaging used in the opt in journey if you want to, or leave the messages as their defaults.

Enter any customised user messages you want to use:

Setting Purpose Default message
Message 1

To prompt the LINE user to enter their email address to confirm opt in.

Important: It is important that the message is unambiguous and states by providing an email address they are consenting to be contacted and by what channels

Thanks for contacting us; for us to message you we need your email address please. Please reply with it to opt in to communications via LINE and email
Response 1 To confirm the email entered is valid and we are opting them in Thank you 👍, please wait...
Response 2 To confirm all is complete and they are opted it All done, thanks for opting in
Response 3 If an error occurs during the opt in process Sorry something went wrong, please send your email again
Response 4

An invalid email address is entered

Note use the token [user_input] if you want to quote what the user entered back in the message

[user_input]' is not a valid email address; if you would like us to be able to message you via LINE please reply with your email address

The logical flow of the opt in process and where the messages are used is illustrated below:
logical-flow.png

Select Submit to complete the setup.

Step 4: Ensure LINE webhooks are enabled

You now need to ensure that the LINE Providers Messaging API settings are correct by following these steps:

  1. Open the LINE Developers Console.
  2. Enter your LINE providers settings.
  3. Select the Messaging API tab.
  4. Ensure that the Webhook URL field has a URL populated.
  5. Ensure the Use webhook option is enabled.
  6. Open the Greeting messages options by selecting Edit at the end of the fields line.
  7. In the Main settings section:
    1. Ensure that Response mode is set to Bot.
    2. You can use a Greet message but be mindful of the user experience with the opt in flow.
  8. In the Detailed settings section:
    1. Ensure that Auto-response is disabled.
    2. Ensure that Webhooks is enabled.

Step 5: Setup complete

You have now performed all the necessary steps to enable Dotdigital to use your LINE Provider to message your LINE users.

The integration has created a new contact datafield in your account called LINE_ID
If this field is populated it indicates an opt in to be messaged via LINE, as the customer must have submitted their email address via the automated opt-in process.

You should not populate the LINE_ID field yourself; it is only intended to be modified by the integration.

To use the LINE Messaging API you will use the LINE Program extension in an Automation Program to call the LINE Messaging API.

Sending a LINE message

You can send LINE messages to any contact that has a populated LINE_ID contact field.

We have created an automation program in your account called Example LINE send that demonstrates how to make a call using the program extension to the LINE Messaging API.

The example is a simple text based message but you can send any message the LINE Messaging API supports. To alter the message select the Line message node in the Example LINE send program.

You should ensure all messaging you send complies with the LINE Messaging API terms.

Adding a LINE message node

  1. Open or create a new program you want to add the LINE message node to.
  2. Drag the Line message program extension node in from the left hand menus Extensions section:
    line-message-node.png
  3. Select the Line message node you added to open it’s settings.
  4. Select the Headers edit button and enter the following, you will need your LINE Channel access token which can be found in the LINE Developers Console in the providers settings, described below:
    1. Enter your LINE providers settings.
    2. Select the Messaging API tab.
    3. Scroll to the bottom of the tab settings and you will see the Channel access token (long-lived) field.
    4. If a value is shown, copy the value and enter it in the settings, or select the Issue button to create a new token.
      Authorization: Bearer <LINE Channel access token>

      e.g.

      Authorization: Bearer BBDeGYq1CZz7fZRuAfATsEEn2A25dfKVhi/Z8kL+saGOkU9SPYKQD38/LZzuCw4scLuTvIL1wPribpD+aKgZXjLXsPoc1La5iP8N94e5LWj1YwQK168/TQv+ZMtV4OPnoldZr5rJdnBSEotEkttZcAdB04t89/1O/w1cDnyilFU=
  5. Select the Body data edit button to enter your message request.
  6. Modify the examples below for the body, create your message send request, or craft a new one using the LINE Messaging API guidance here, but ensure you copy in the "to": "@LINE_ID@" addressing element so it goes to the selected contact:

Text message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "type": "text",
            "text": "Example text message"
      }
  ]
}

Sticker message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "type": "sticker",
            "packageId": "446",
            "stickerId": "1988"
      }
  ]
}

Image message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "type": "image",
            "originalContentUrl": "https://example.com/original.jpg",
            "previewImageUrl": "https://example.com/preview.jpg"
      }
  ]
}

Video message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "type": "video",
            "originalContentUrl": "https://example.com/original.mp4",
            "previewImageUrl": "https://example.com/preview.jpg"
      }
  ]
}

Audio message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "type": "audio",
            "originalContentUrl": "https://example.com/original.m4a",
            "duration": 60000
      }
  ]
}

Location message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "type": "location",
            "title": "my location",
            "address": "1-6-1 Yotsuya, Shinjuku-ku, Tokyo, 160-0004, Japan",
            "latitude": 35.687574,
            "longitude": 139.72922
      }
  ]
}

Imagemap message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "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
                  }
              }
          ]
      }
  ]
}

Button template message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "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"
                  }
              ]
          }
      }
  ]
}

Confirm template message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "type": "template",
            "altText": "this is a confirm template",
            "template": {
                "type": "confirm",
                "text": "Are you sure?",
                "actions": [
                  {
                      "type": "message",
                      "label": "Yes",
                      "text": "yes"
                  },
                  {
                      "type": "message",
                      "label": "No",
                      "text": "no"
                  }
              ]
          }
      }
  ]
}

Carousel template message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "type": "template",
            "altText": "this is a carousel template",
            "template": {
                "type": "carousel",
                "columns": [
                  {
                      "thumbnailImageUrl": "https://example.com/bot/images/item1.jpg",
                      "imageBackgroundColor": "#FFFFFF",
                      "title": "this is menu",
                      "text": "description",
                      "defaultAction": {
                          "type": "uri",
                          "label": "View detail",
                          "uri": "http://example.com/page/123"
                    },
                      "actions": [
                        {
                              "type": "postback",
                              "label": "Buy",
                              "data": "action=buy&itemid=111"
                        },
                        {
                              "type": "postback",
                              "label": "Add to cart",
                              "data": "action=add&itemid=111"
                        },
                        {
                              "type": "uri",
                              "label": "View detail",
                              "uri": "http://example.com/page/111"
                        }
                    ]
                  },
                  {
                      "thumbnailImageUrl": "https://example.com/bot/images/item2.jpg",
                      "imageBackgroundColor": "#000000",
                      "title": "this is menu",
                      "text": "description",
                      "defaultAction": {
                          "type": "uri",
                          "label": "View detail",
                          "uri": "http://example.com/page/222"
                    },
                      "actions": [
                        {
                              "type": "postback",
                              "label": "Buy",
                              "data": "action=buy&itemid=222"
                        },
                        {
                              "type": "postback",
                              "label": "Add to cart",
                              "data": "action=add&itemid=222"
                        },
                        {
                              "type": "uri",
                              "label": "View detail",
                              "uri": "http://example.com/page/222"
                        }
                    ]
                  }
              ],
                "imageAspectRatio": "rectangle",
                "imageSize": "cover"
          }
      }
  ]
}

Image carousel template message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "type": "template",
            "altText": "this is a image carousel template",
            "template": {
                "type": "image_carousel",
                "columns": [
                  {
                      "imageUrl": "https://example.com/bot/images/item1.jpg",
                      "action": {
                        "type": "postback",
                        "label": "Buy",
                        "data": "action=buy&itemid=111"
                    }
                  },
                  {
                      "imageUrl": "https://example.com/bot/images/item2.jpg",
                      "action": {
                        "type": "message",
                        "label": "Yes",
                        "text": "yes"
                    }
                  },
                  {
                      "imageUrl": "https://example.com/bot/images/item3.jpg",
                      "action": {
                        "type": "uri",
                        "label": "View detail",
                        "uri": "http://example.com/page/222"
                    }
                  }
              ]
          }
      }
  ]
}

Flex message

{
    "to": "@LINE_ID@",
    "messages": [
      {
            "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"
                }
              ]
            }
          }
      }
  ]
}
Did you find this article helpful?

Can we help?

Thanks for using Dotdigital. If you need more help or support, then contact our support team.