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

FeatureSupportRemarks
text messagesyesThe maximum length of a LINE message is 5.000 characters, and it must be UTF-8 encoded.
mediayesThe 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: imagesyesMaximum file size for an uploaded image is 10 MB. Supported formats: png, jpeg and jpg.
media: videosyesMaximum file size for an uploaded image is 200 MB. Supported formats: mp4.
media: audiono
rich card messageyesSupport for button and confirm templates.
rich card carouselyesSupport for button and image carousel templates. Maximum of 10 templates per carousel supported.
quick repliesno
sticker messageno
location messageno

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

TextMediaSuggestionsHeaderOutput
xxxxNot supported
xxxNot supported
xxxNot supported
xxNot supported
xxNot supported
xxNot supported
xNot supported
xxNot supported
xNot supported
xxxText message
xxxMedia message
xxText and media messages
xxConfirm template (Always 2 reply buttons) or button template (max 4 buttons)
xButton template (Max. 4 buttons)
xButton 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 typeSupported formatsMime typeSupported size maximum
Imagepng, jpeg, jpgimage/png, image/jpeg, image/jpg10MB
Videomp4video/mp4200MB

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:

FieldSupportRequiredRemarks
cardsYesYes (for carousels)Max. 10 allowed per (carousel) message.
headerYesNoDisplayed as the title. Max. 40 characters.
textYesYes 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 URLYesNoImage format: JPEG or PNG
Max. width: 1024px
Max. file size: 10 MB
defaultActionYesNoDefault action that will be triggered when the image, title, or text area is tapped.
suggestionsYesYesSuggestion 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.

ActionRemarks
ReplyThe 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.
OpenUrlThe 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.