Created
October 5, 2019 02:23
-
-
Save jirawatee/f1c0e10d543dd289752b5902fdf3a0eb to your computer and use it in GitHub Desktop.
Appointment confirmation
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.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' } | |
); | |
return agent.add(`ยืนยันนัด ` + appointmentTimeString + ` ไหมครับ?`); | |
} | |
let intentMap = new Map(); | |
intentMap.set('Appointment', confirmAppointment); | |
agent.handleRequest(intentMap); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment