Skip to content

Instantly share code, notes, and snippets.

@jirawatee
Created May 27, 2019 15:12
Show Gist options
  • Save jirawatee/c6125cf1039112f365744c12a34e2aeb to your computer and use it in GitHub Desktop.
Save jirawatee/c6125cf1039112f365744c12a34e2aeb to your computer and use it in GitHub Desktop.
Messaging API - Push, Reply and Broadcast
// 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