1. Documents
  2. Link messages

Link messages

Your application can send link messages to specific users via the Link Message API. To send link messages, you must add a link message template for the message you want to send. The Channel Console has a feature where you can manage link message templates.

Opening the link message templates page

To open the link message templates page:

  1. Click the Channel you want to add a new template to from the list on the left.
  2. Click Link message templates.

Adding new templates

Fill in each field of the registration form to add a new template. Descriptions of each field are as follows:

Field Description
Template ID Identifier of the template. Used when sending messages with an API.
Template text Message displayed in the link. You can make characters bold by using the <b> and </b> tags. If you want to use the characters, “<" and ">“, they must must be escaped. Max length: 200 characters.
Note: Cannot consist only of placeholders.
Preview image URL URL of the preview image.
Sub text An additional description for the link. The size of the sub text is smaller than than the template text. Max length: 50 characters.
Link text The default link text is “Check now”. Use this attribute to change the default link text. Max length: 16 characters.
App Store URL App Store URL for your application. User is redirected to this URL if your application is not installed.
Google Play URL Google Play URL for your application. User is redirected to this URL if your application is not installed.
iPhone link URI URI scheme used to launch your iOS application.
Android link URI URI scheme used to launch your Android application.
Web link URL URL of the website where you want the link to navigate to.

The iPhone/Android link URI fields and Web link URL fields are mutually exclusive. If you enter a web link URL, the iPhone/Android link URI fields cannot be filled in.

The placeholder string which is enclosed between “${” and “}” can be embedded in the template text, sub text, link text and each URL/URI. If you would like to specify a fixed string, you don’t need to use the placeholder. For example, you can specify the following value which has one placeholder:

Hey, ${person_name} got a new high score!

When you are finished filling in each field, click SUBMIT THIS NEW TEMPLATE. If successful, your newly registered template will be displayed in the Link message templates page.

Sending link messages using an API

Prerequisites

  • Access token with SEND_MESSAGE permission issued.

Request

HTTP Method POST
Endpoint URL https://api.line.me/v1/events
(Deprecated) https://channel-apis.line.naver.jp/v1/events
Necessary Request Headers Content-Type: application/json
X-Line-ChannelToken: Access Token
On the Link Message API, the JSON string, which describes the event to be posted, must be specified in the request body. The event information consists of the following properties.
Property Name Description
to Receiver user’s MID array list.
toChannel 1341301715
eventType “137299299800026303”
content/previewUrl URL of the preview image. This parameter is optional. The previewUrl value is applied using the following rules:
  • If a sent JSON string contains the previewUrl property, its URL will be applied.
  • If the previewUrl property is omitted, the Preview Image URL defined in the Link Message Template will be applied.
  • If the previewUrl property is omitted and the template does not have a Preview Image URL, the Channel icon image will be applied.
content/templateId Template identifier. (You can set this value)
content/textParams If the Template (text) value includes placeholders, specify the replaced values using this property. Characters must be escaped using the following rules:
  • < = &lt;
  • > = &gt;
  • ” = &quot;
  • ‘ = &#39;
  • & = &amp;
content/subTextParams If the Sub text value includes placeholders, specify the replaced values using this property.
content/linkTextParams If the Link text value includes placeholders, specify the replaced values using this property.
content/aLinkUriParams If the Android link URI value includes placeholders, specify the replaced values using this property.
content/iLinkUriParams If the iPhone link URI value includes placeholders, specify the replaced values using this property.
content/linkUriParams If the Web link URL value includes placeholders, specify the replaced values using this property.

Example

{
  "to":["u668d5ad7e289428ef97d4ceb7841b0ad"],
  "toChannel":1341301715,
  "eventType":"137299299800026303",
  "content":{
    "templateId":"template_id_3",
    "previewUrl":"http://example.com/images/brown.png",
    "textParams":{
      "text_param":"brown"
    },
    "subTextParams":{
      "subtext_param":"Cony"
    },
    "linkTextParams":{
      "lt_p":"Happy"
    },
    "aLinkUriParams":{
      "alu_p":"foo"
    },
    "iLinkUriParams":{
      "ilu_p":"bar"
    },
    "linkUriParams":{
      "lu_p":"baz"
    }
  }
}

Response

The result of this API will be returned in JSON format.
Property Name Type Description
version Integer String granting the sent event.
timestamp Long Sent date and time.
messageId String ID to identify the sent event.
failed Array of String ID string of user who failed to receive the event. If there is no error, this property has zero-length array.

Example

{
  "version":"1",
  "timestamp":1370941880118,
  "messageId":"1370941880118",
  "failed":["u123abc", ...]
}