LINE
Our business messaging API supports sending and receiving LINE messages.
Being able to send LINE messages requires requesting access via the Channels portal. Without onboarding LINE via the portal, you can not make use of this part of the API.
Fact sheet
Feature | Support | Remarks |
---|---|---|
text messages | yes | The maximum length of a LINE message is 5.000 characters, and it must be UTF-8 encoded. |
media | yes | The media name attribute should end in the proper file extension. Only one media file is allowed per message. When the linked media doesn't exist/can't be found, the message will not be sent at all. |
media: images | yes | Maximum file size for an uploaded image is 10 MB. Supported formats: png, jpeg and jpg. |
media: videos | yes | Maximum file size for an uploaded image is 200 MB. Supported formats: mp4. |
media: audio | no | |
rich card message | yes | Support for button and confirm templates. |
rich card carousel | yes | Support for button and image carousel templates. Maximum of 10 templates per carousel supported. |
quick replies | no | |
sticker message | no | |
location message | no |
Onboarding
Onboarding pages for LINE are in development, in the meantime you are welcome to onboard for LINE via your customer success manager.
Your account user id
After the onboarding process is completed successfully, a unique user id will be created for the onboarded account. This user id is necessary to send messages to LINE users. You can find the user id in the message log after sending a message to the account (Check the recipient column for your user id).
Sending messages
Input matrix
Text | Media | Suggestions | Header | Output |
---|---|---|---|---|
x | x | x | x | Not supported |
x | x | x | √ | Not supported |
x | x | √ | x | Not supported |
x | x | √ | √ | Not supported |
x | √ | x | √ | Not supported |
x | √ | √ | x | Not supported |
x | √ | √ | √ | Not supported |
√ | x | x | √ | Not supported |
√ | √ | x | √ | Not supported |
√ | x | x | x | Text message |
x | √ | x | x | Media message |
√ | √ | x | x | Text and media messages |
√ | x | √ | x | Confirm template (Always 2 reply buttons) or button template (max 4 buttons) |
√ | x | √ | √ | Button template (Max. 4 buttons) |
√ | √ | √ | x | Button template (Max. 4 buttons) |
√ | √ | √ | √ | Button template (Max. 4 buttons) |
Text
Direct message with plain text content
The example below will send a simple text-only LINE message.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your User ID",
"to": [
{
"number": "Recipients User ID"
}
],
"allowedChannels": [
"Line"
],
"body": {
"content": ""
},
"richContent": {
"conversation": [
{
"text": "CM.com - Be part of it."
}
]
}
}
]
}
}
Media
Media type | Supported formats | Mime type | Supported size maximum |
---|---|---|---|
Image | png, jpeg, jpg | image/png, image/jpeg, image/jpg | 10MB |
Video | mp4 | video/mp4 | 200MB |
Direct message with image
In the example below, we send a simple rich content message that contains an image.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your User ID",
"to": [
{
"number": "Recipients user ID"
}
],
"body": {
"content": ""
},
"allowedChannels": [
"Line"
],
"richContent": {
"conversation": [
{
"media": {
"mediaName": "your-image.png",
"mediaUri": "your-image.png",
"mimeType": "image/png"
}
}
]
}
}
]
}
}
Direct message with video
In the example below, we send a simple rich content message that contains a video.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your User ID",
"to": [
{
"number": "Recipients User ID"
}
],
"body": {
"content": ""
},
"allowedChannels": [
"Line"
],
"richContent": {
"conversation": [
{
"media": {
"mediaName": "your-video.mp4",
"mediaUri": "your-video-url.mp4",
"mimeType": "video/mp4"
}
}
]
}
}
]
}
}
Rich card
Rich cards, called templates messages in LINE, offer a way for you to offer a richer in-conversation experience than standard text messages by integrating buttons, images and more alongside text in a single message. Rich cards can be used for many purposes, such as displaying product information or asking the message recipient to choose from a pre-determined set of options.
The following restrictions apply for a rich card message:
Field | Support | Required | Remarks |
---|---|---|---|
cards | Yes | Yes (for carousels) | Max. 10 allowed per (carousel) message. |
header | Yes | No | Displayed as the title. Max. 40 characters. |
text | Yes | Yes for single rich card messages. (Button and Confirm templates) No for carousel messages. | Max. character limit: 160 (no image or title) Max. character limit: 60 (message with an image or title) Will also be used when a user receives a message as the notification text. For carousels, a standard notification text will be displayed: "You've received a new message" |
media URL | Yes | No | Image format: JPEG or PNG Max. width: 1024px Max. file size: 10 MB |
defaultAction | Yes | No | Default action that will be triggered when the image, title, or text area is tapped. |
suggestions | Yes | Yes | Suggestion will be used as buttons. Max. 4 buttons per card, and all cards must have the same amount of buttons. |
The following actions are supported for LINE as rich card buttons.
Action | Remarks |
---|---|
Reply | The maximum length of the label is 20 characters. (for image carousels the max. is 12 characters) The label text is also the response that will be sent when clicked. |
OpenUrl | The maximum length of the label is 20 characters. (for image carousels the max is 12 characters) The maximum length of the URL is 1000 characters. |
A single rich card as button template
In the example below, we send a rich card that will be sent as a button template to LINE. The rich card is composed of a title, a text, a media image, a defaultAction and two suggestions. The button template can also be sent without a header, image, and defaultAction.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your User ID",
"to": [
{
"number": "Recipients User ID"
}
],
"body": {
"content": ""
},
"allowedChannels": [
"Line"
],
"richContent": {
"conversation": [
{
"header": "We are CM.com!",
"text": "Visit our website or start a chat with one of our employees!",
"media": {
"mediaName": "your-image.png",
"mediaUri": "your-image.png",
"mimeType": "image/png"
},
"defaultAction": {
"action": "OpenUrl",
"label": "Visit our website!",
"url": "https://cm.com"
},
"suggestions": [
{
"action": "OpenUrl",
"label": "Visit our website!",
"url": "https://cm.com"
},
{
"action": "Reply",
"label": "I want to chat!"
}
]
}
]
}
}
]
}
}
A single rich card as confirm template
In the example below, we send a rich card that will be sent as a confirm template to LINE. The rich card is composed of a text and two suggestions. A confirm template can only contain a text and two buttons max.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your User ID",
"to": [
{
"number": "Recipients User ID"
}
],
"body": {
"content": ""
},
"allowedChannels": [
"Line"
],
"richContent": {
"conversation": [
{
"text": "Do you want to chat with one of our employees?",
"suggestions": [
{
"action": "Reply",
"label": "Yes"
},
{
"action": "Reply",
"label": "No"
}
]
}
]
}
}
]
}
}
A carousel template message containing button templates
In the example below, we send a rich content message that will create a carousel of button templates in LINE. Carousel template messages can contain max. 10 button templates and each button template in the carousel can contain max. 3 buttons and must have a text, a header is optional.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your User ID",
"to": [
{
"number": "Recipients User ID"
}
],
"body": {
"content": ""
},
"allowedChannels": [
"Line"
],
"richContent": {
"conversation": [
{
"carousel": {
"cards": [
{
"header": "We are CM.com!",
"text": "Visit our website or start a chat with one of our employees!",
"media": {
"mediaName": "your-image.png",
"mediaUri": "your-image.png",
"mimeType": "image/png"
},
"suggestions": [
{
"action": "OpenUrl",
"label": "Visit our website!",
"url": "https://cm.com"
},
{
"action": "Reply",
"label": "I want to chat!"
}
]
},
{
"header": "Conversational Channels",
"text": "Here's a selection of some of the channels we support!",
"media": {
"mediaName": "your-image.png",
"mediaUri": "your-image.png",
"mimeType": "image/png"
},
"suggestions": [
{
"action": "OpenUrl",
"label": "WhatsApp!",
"url": "https://www.cm.com/whatsapp/"
},
{
"action": "OpenUrl",
"label": "Instagram!",
"url": "https://www.cm.com/instagram-messaging"
}
]
}
]
}
}
]
}
}
]
}
}
A carousel template message containing images
In the example below, we send a rich content message that will create a carousel of image in LINE. Image carousel template messages can contain max. 10 cards. Each card must have an image URL and a suggestion that will be used as the action when the image gets clicked.
{
"messages": {
"authentication": {
"producttoken": "Your product token"
},
"msg": [
{
"from": "Your User ID",
"to": [
{
"number": "Recipients User ID"
}
],
"body": {
"content": ""
},
"allowedChannels": [
"Line"
],
"richContent": {
"conversation": [
{
"carousel": {
"cards": [
{
"media": {
"mediaName": "your-image.png",
"mediaUri": "your-image.png",
"mimeType": "image/png"
},
"suggestions": [
{
"action": "OpenUrl",
"label": "Visit",
"url": "https://cm.com"
}
]
},
{
"media": {
"mediaName": "your-image.png",
"mediaUri": "your-image.png",
"mimeType": "image/png"
},
"suggestions": [
{
"action": "OpenUrl",
"label": "Visit",
"url": "https://cm.com"
}
]
}
]
}
}
]
}
}
]
}
}
Receiving messages / Inbound flow
Since LINE is used for 2-way communication (chat) it is important to also implement an Inbound flow. You can find more information about how to do this using our API documentation of the Inbound webhook.
Updated about 2 months ago