Introduction
MoEngage <> Line
Integration
Prerequisites
Line allows both promotional and non-promotional messaging to users as long your brand has secured users’ consent. To send messages to users, you must meet one of two conditions:
- Users who have added your Line official account as a friend
- Users who haven’t added your Line official account as a friend but have sent a message to your Line official account (excluding users who have blocked your LINE official account).
REQUIREMENT | DESCRIPTION |
---|---|
Line business account | A Line official business account is required to use this integration When sending Line messages, your messages will all be associated with your Line official account, resulting in users seeing your account name and page. |
Messaging API channel | When enabling the use of the messaging API in the LINE official account manager , a messaging API channel is created. This will be the channel you use to communicate with your customers. |
Channel access tokens | The channel access token will allow you to send messages to users that have added your Line official account as a friend. This token can be found in the Line Developer Console under the Messaging API tab. |
Line user IDs | You will need to have users’ Line IDs (this ID is different from users’ usernames) to send messages on Line. Once a user adds your Line official account as a friend, you can access the user’s Line ID through Line’s Users API. |
Step 1: Collect customer Line IDs
To send messages in Line, you need to collect your users’ Line IDs to identify your user and interact with them consistently. Line IDs are not the same as the user’s Line usernames. Line IDs are generated by Line and can be used when interacting with Line’s APIs.
Line IDs can be obtained using the Line User ID API . This endpoint will return a list of Line IDs for all users who have friended your LINE official account or sent your account a message and have not blocked you.
When making a GET request to the endpoint https://api.line.me/v2/bot/followers/ids
, you will get the line IDs of followers.
Step 2: Save user's Line ID on MoEngage
Once you obtain a list of Line IDs, you will send them to MoEngage as a line_id
- custom tracked user attribute/property. You can save this data to MoEngage either using:
- User Data API or
- Upload them using User Imports inside MoEngage.
Step 3: Create Connector Campaign on MoEngage to send Line Message
To create a connector campaign on MoEngage,
1. Navigate to Create Campaign >> Connectors >> Custom and choose delivery type most suitable to your needs
2. Choose Segment of users for whom line_id exists (You can combine with other Segment criteria)
3. On step 2 of the campaign,
- Select method as POST
- Add Webhook URL as :
https://api.line.me/v2/bot/message/push
- In Headers, add
- Content-Type as application/json
- Authorization as Bearer
{channel access token}
(Channel access token is what you would have captured as mentioned above)
- In Body, choose Raw and use the content depending on what kind of message object you want to send out. You can look at different message objects here.
Here are few content samples for different message types:
{
"to": "{{UserAttribute['line_id']}}",
"messages":[
{
"type":"text",
"text":"Hello, world1"
}
]
}
{
"to": "{{UserAttribute['line_id']}}",
"messages":[
{
"type": "image",
"originalContentUrl": "https://example.com/original.jpg",
"previewImageUrl": "https://example.com/preview.jpg"
}
]
}
{
"to": "{{UserAttribute['line_id']}}",
"messages":[
{
"type": "video",
"originalContentUrl": "https://example.com/original.mp4",
"previewImageUrl": "https://example.com/preview.jpg"
}
]
}
4. At this point, your campaign should be ready to test and send. You can also test your connector configuration using the Test functionality available on Step 2 of Create Connector Campaign
If your test user successfully receives the message, your set-up is good to go. You can go ahead and Publish the campaign.