I have a demo bot which takes in the user's date & time as inputs, and just repeats it back to them. However, it gets repeated in the ISO-8601 format, which I don't want. I managed to format in the inline editor for Google Assistant, but it doesn't work in Facebook Messenger. Is there any way I can format it in the inline editor for Messenger as well?
This is the code I'm using, it formats it correctly in the test console, but on messenger in still uses the responses that I entered in Dialogflow. (e.g. Sure thing, I'll hook you up with a tune-up at $Time on $Date. See you then!)
const functions = require('firebase-functions');
const {dialogflow} = require('actions-on-google');
const WELCOME_INTENT = 'Default Welcome Intent';
const FALLBACK_INTENT = 'Default Fallback Intent';
const TUNEUP_INTENT = 'Book Tune-Up';
const DATE_ENTITY = 'Date';
const TIME_ENTITY = 'Time';
const timeZone = 'Europe/Belgrade';
const app = dialogflow();
function getLocaleTimeString(dateObj){
return dateObj.toLocaleTimeString('en-US', { hour: 'numeric', hour12: true, timeZone: timeZone });
}
function getLocaleDateString(dateObj){
return dateObj.toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric', timeZone: timeZone });
}
app.intent(TUNEUP_INTENT, (conv) => {
const date = getLocaleDateString(new Date(conv.parameters[DATE_ENTITY]));
const time = getLocaleTimeString(new Date(conv.parameters[TIME_ENTITY]));
const responses = [`Sure thing, I'll hook you up with a tune-up at ${time} on ${date}. See you then!`,
`Cool! So to recap - I'll book you with a tune-up on ${date} at ${time}. Thanks for booking!`,
`Great, you're booked for ${date} at ${time}. See you then!`];
conv.ask(responses[Math.floor(Math.random() * responses.length)]);
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);