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
{ | |
"functions": { | |
"predeploy": [ | |
"npm --prefix \"$RESOURCE_DIR\" run lint" | |
] | |
}, | |
"hosting": { | |
"public": "public", | |
"ignore": [ | |
"firebase.json", |
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
{ | |
"line": { | |
"type": "flex", | |
"altText": "Rabbit LINE Pay", | |
"contents": { | |
"type": "carousel", | |
"contents": [ | |
{ | |
"type": "bubble", | |
"hero": { |
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
<script> | |
liff.init({ liffId: "1234567890-XXXXXXXXX" }, () => { | |
if (liff.isLoggedIn()) { | |
// ขั้นตอน 4.4 รออยู่ | |
} else { | |
liff.login(); | |
} | |
}, err => console.error(err.code, error.message)); | |
</script> |
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
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>My LIFF v2</title> | |
<style> | |
#pictureUrl { display: block; margin: 0 auto } | |
</style> | |
</head> | |
<body> |
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
<script> | |
const medium = 'https://medium.com/linedevth/'; | |
const queryString = decodeURIComponent(window.location.search).replace("?liff.state=", ""); | |
const params = new URLSearchParams(queryString); | |
const id = params.get('id'); | |
if (id != null && id != '') { | |
window.location.assign(medium + id); | |
} else { | |
window.location.assign("https://developers.line.biz"); | |
} |
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
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => { | |
const agent = new WebhookClient({ request, response }); | |
function confirmAppointment(agent) { | |
const dateTimeStart = new Date( | |
Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time.split('T')[1]) | |
); | |
const appointmentTimeString = dateTimeStart.toLocaleString( | |
'en-US', | |
{ weekday: 'short', day: 'numeric', month: 'short', hour: 'numeric', minute: 'numeric', timeZone: 'Asia/Bangkok' } | |
); |
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
"use strict"; | |
const { WebhookClient, Payload } = require("dialogflow-fulfillment"); | |
const functions = require("firebase-functions"); | |
const { google } = require('googleapis'); | |
const calendarId = "[email protected]"; | |
const serviceAccount = { | |
"type": "service_account", | |
"project_id": "line-bot", |
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
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => { | |
const agent = new WebhookClient({ request, response }); | |
function confirmAppointment(agent) { | |
// ... | |
} | |
function makeAppointment(agent) { | |
const appointment_type = agent.parameters.AppointmentType; | |
const dateTimeStart = new Date( |
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
function createCalendarEvent(dateTimeStart, dateTimeEnd, appointment_type) { | |
return new Promise((resolve, reject) => { | |
calendar.events.list({ | |
auth: serviceAccountAuth, // List events for time period | |
calendarId: calendarId, | |
timeMin: dateTimeStart.toISOString(), | |
timeMax: dateTimeEnd.toISOString() | |
}, (err, calendarResponse) => { | |
// Check if there is a event already on the Calendar | |
if (err || calendarResponse.data.items.length > 0) { |
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
{ | |
"host": "xxxxx.cloudfunctions.net", | |
"user-agent": "LineBotWebhook/1.0", | |
"transfer-encoding": "chunked", | |
"accept": "*/*", | |
"content-type": "application/json;charset=UTF-8", | |
"forwarded": "for=\"xxx.xxx.xxx.xxx\";proto=https", | |
"function-execution-id": "fh8e8wtjjumk", | |
"x-appengine-city": "minato city", | |
"x-appengine-citylatlong": "xxx,yyy", |