Skip to content

Instantly share code, notes, and snippets.

View LINE bot with Firebase Funtions - use Region
exports.createCustomToken = functions.region("asia-east2").https.onRequest((request, response) => {
});
View LINE bot with Firebase Funtions - not use Region
exports.createCustomToken = functions.https.onRequest((request, response) = {
});
View LINE Bot - Reply Message Manual
const reply = req => {
return request({
method: "POST",
uri: `${LINE_MESSAGING_API}/reply`,
headers: LINE_HEADER,
body: JSON.stringify({
replyToken: req.body.events[0].replyToken,
messages: [
{
type: "text",
View keybase.md

Keybase proof

I hereby claim:

  • I am pamornt on github.
  • I am pamornt (https://keybase.io/pamornt) on keybase.
  • I have a public key ASALzR5K2DKX9wplZE7IK-avGhSPztk_7jEirr_D2gAY6go

To claim this, I am signing this object:

View LINE Bot - ThaiPost - GetToken
let promise_token = new Promise(resolve => {
var options = {
method: 'POST',
uri: 'https://trackapi.thailandpost.co.th/post/api/v1/authenticate/token',
strictSSL: false,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Token ' + config.thaipost.token
}
};
View LINE Bot - ThaiPost - GetItems
let promise_track = new Promise(resolve => {
var options = {
method: 'POST',
uri: 'https://trackapi.thailandpost.co.th/post/api/v1/track',
strictSSL: false,
body: JSON.stringify(params),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Token ' + access_token.token
}
View LINE Bot - ThaiPost - Flex Message
let item_json = [];
let { response } = tracks;
let { items } = response;
let key = Object.keys(tracks.response.items);
if (key.length > 0) {
let bgcolor;
items[key[0]].forEach(function(detail) {
bgcolor = (detail.delivery_status == 'S') ? '#ABEBC6' : '#EEEEEE';
const item_temp = {
View LINE Bot - Return Flex Message
const reply_track = (req, payload) => {
return request({
method: `POST`,
uri: `${LINE_MESSAGING_API}/reply`,
headers: LINE_HEADER,
body: JSON.stringify({
replyToken: req.body.events[0].replyToken,
messages: [
{
"type": "flex",
View LINE Bot - Return Not Found Message
const reply_notfound = (req) => {
return request({
method: `POST`,
uri: `${LINE_MESSAGING_API}/reply`,
headers: LINE_HEADER,
body: JSON.stringify({
replyToken: req.body.events[0].replyToken,
messages: [
{
type: `text`,
View LINE Bot - ThaiPost - Config
{
"line": {
"channelAccessToken": "",
"channelSecret": ""
},
"thaipost": {
"token": ""
}
}