Skip to content

Instantly share code, notes, and snippets.

@chaintng
Last active February 24, 2018 14:16
Show Gist options
  • Save chaintng/423932d96aad4ae032551e0f0ac3a4a1 to your computer and use it in GitHub Desktop.
Save chaintng/423932d96aad4ae032551e0f0ac3a4a1 to your computer and use it in GitHub Desktop.
rich-menu-api.js
const config = require('../config.js')
const request = require('request-promise')
// When user send NEXT, Bot will call Rich Menu API for attaching Rich Menu Page 2 to that user
const nextPage = (userId) => {
return request({
method: 'POST',
uri: `https://api.line.me/v2/bot/user/${userId}/richmenu/${config.cryptoPage2RichMenuId}`,
headers: {
Authorization: `Bearer ${config.channelAccessToken}`
},
json: true
})
}
// When user send PREVIOUS, Bot will call Rich Menu API for detach current Rich Menu,
// which will show the default rich menu that set via Admin Console
const previousPage = (userId) => {
return request({
method: 'DELETE',
uri: `https://api.line.me/v2/bot/user/${userId}/richmenu`,
headers: {
Authorization: `Bearer ${config.channelAccessToken}`
},
json: true
})
}
module.exports = {
nextPage,
previousPage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment