This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta | |
name="viewport" | |
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover" | |
/> | |
<title>LIFF: LINE Front-end Framework</title> | |
<script src="https://static.line-scdn.net/liff/edge/2/sdk.js"></script> |
This file contains 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
// Import stylesheets | |
import './style.css'; | |
// Body element | |
const body = document.getElementById('body'); | |
// Button elements | |
const btnSend = document.getElementById('btnSend'); | |
const btnClose = document.getElementById('btnClose'); | |
const btnShare = document.getElementById('btnShare'); |
This file contains 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
{ | |
"type": "bubble", | |
"body": { | |
"type": "box", | |
"layout": "vertical", | |
"contents": [ | |
{ | |
"type": "text", | |
"text": "จำนวนผู้ติดเชื้อรายวัน", | |
"weight": "bold", |
This file contains 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
import * as functions from "firebase-functions"; | |
import * as dialogflow from "@google-cloud/dialogflow"; | |
import axios from "axios"; | |
const projectId = "<DIALOGFLOW PROJECTID>"; | |
const LINE_HEADER_DEV = { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer <DEV CHANNEL ACCESS TOKEN>", | |
}; | |
const LINE_HEADER_PROD = { |
This file contains 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
import * as functions from "firebase-functions"; | |
import * as dialogflow from "@google-cloud/dialogflow"; | |
const projectId = "multiple-env-pafg"; | |
// // Start writing Firebase Functions | |
// // https://firebase.google.com/docs/functions/typescript | |
let dialogflowEnv = ""; | |
// | |
export const webHook = functions.https.onRequest((request, response) => { | |
if (request.body.destination === "U19476f0931c6ac37972a6b7f4b4321c6") { | |
dialogflowEnv = "draft"; |
This file contains 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
import * as functions from "firebase-functions"; | |
// // Start writing Firebase Functions | |
// // https://firebase.google.com/docs/functions/typescript | |
let dialogflowEnv = ""; | |
// | |
export const webHook = functions.https.onRequest((request, response) => { | |
if (request.body.destination === "U19476f0931c6ac37972a6b7f4b4321c6") { | |
dialogflowEnv = "draft"; | |
} else if (request.body.destination === "U92a6f010a3fd78085b8763159a04772b") { | |
dialogflowEnv = "production"; |
This file contains 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
import * as functions from "firebase-functions"; | |
// // Start writing Firebase Functions | |
// // https://firebase.google.com/docs/functions/typescript | |
// | |
export const webHook = functions.https.onRequest((request, response) => { | |
console.log(request.body); | |
const events = request.body.events; | |
events.forEach( async (event: any) => { | |
console.log(event); | |
if (event.type === "message") { |
This file contains 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
// Verify Events request must array | |
const events = request.body.events | |
if(!events || !Array.isArray(events)) { | |
response.status(200).send('not have events') | |
return | |
} | |
This file contains 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
exports.LINEwebhook = functions.region(region).https.onRequest(async(request, response) => { | |
console.log('🚀 Start Webhook!!', request.body ) | |
// Verify Signature | |
const verify = await verify_signature(request, response) | |
if(!verify) { | |
response.status(200).send('Unauthorized') | |
return | |
} |
This file contains 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
const savePointVideoComplete = async(event) => { | |
const replyToken = event.replyToken | |
let messages = '' | |
const pointExists = await checkPointExists(event) | |
if (pointExists) { | |
messages = [{ 'type': 'text', 'text': '🎉 ขอบคุณที่รับชมวีดีโอ คุณเคยได้รับคะแนนกิจกรรมนี้ไปแล้ว 🎉' }] | |
} else { | |
await collectPoint(event) | |
messages = [{ 'type': 'text', 'text': '🎉 ขอบคุณที่รับชมวีดีโอ รับคะแนนไปเลย 10 คะแนน 🎉' }] | |
} |
NewerOlder