Created
May 27, 2019 15:12
-
-
Save jirawatee/c6125cf1039112f365744c12a34e2aeb to your computer and use it in GitHub Desktop.
Messaging API - Push, Reply and Broadcast
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Push Message | |
const push = (userId, msg, quickItems) => { | |
return request.post({ | |
headers: LINE_HEADER, | |
uri: `${LINE_MESSAGING_API}/push`, | |
body: JSON.stringify({ | |
to: userId, | |
messages: [{ type: "text", text: msg, quickReply: quickItems }] | |
}) | |
}) | |
} | |
// Reply Message | |
const reply = (token, payload) => { | |
return request.post({ | |
uri: `${LINE_MESSAGING_API}/reply`, | |
headers: LINE_HEADER, | |
body: JSON.stringify({ | |
replyToken: token, | |
messages: [payload] | |
}) | |
}) | |
} | |
// Broadcast Messages | |
const broadcast = (msg) => { | |
return request.post({ | |
uri: `${LINE_MESSAGING_API}/broadcast`, | |
headers: LINE_HEADER, | |
body: JSON.stringify({ | |
messages: [{ type: "text", text: msg }] | |
}) | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment