I am using the inline editor for Dialogflow to manipulate user data and query my database in.js, with that, I also want the chatbot to answer questions like:
"When is my next Art test."
As the admin I know Art tests are every 3 weeks on Wednesday throughout the year, but how do I translate that into a chatbot response, something like;
"Your next art test is Wednesday 8th August", Or even, "Your next test is Today!"
I have looked at this which is different ways to initiate js times, but none seem to fit what I'm looking for.
I have created a function for time as below, which is where I assume I'd have to make the calculation:
function getDate(agent){
var today = new Date();
}
And the response would be something like:
function getTestDate(agent){
agent.add('Your next test date is' + today); #etc
}
Lastly I have seen this other post on stack calculating days between two dates, whilst this could work I'm not too sure how I can implement this into a Dialogflow environment.
I don't think moment.js can work within the inline editor, but if it did, It looks like it would be easy, per the example here:
moment([2007, 0, 29]).fromNow(); // 4 years ago
moment([2007, 0, 29]).fromNow(true); // 4 years
Then I could simply do the fromNow() command in each function for different dates, and idea how something like this could be interpreted to normal js?
UPDATE
Not got anywhere with this yet but had another idea, is there anyway to identify the month and from there trigger a response? For example can I create a function that identifies the date right now, then i'll be able to write the 3/4 test dates as a text response:
function (getTestDate(agent){
if(date) == May
} agent.add('Tests for May are....etc')