Skip to content

Instantly share code, notes, and snippets.

@jirawatee
Created October 5, 2019 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jirawatee/f1c0e10d543dd289752b5902fdf3a0eb to your computer and use it in GitHub Desktop.
Save jirawatee/f1c0e10d543dd289752b5902fdf3a0eb to your computer and use it in GitHub Desktop.
Appointment confirmation
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