How to extract the current date in a watson session

I need to create a condition in the Watson Conversation dialog box as follows:

if "date date" <04-15-2017 do something. otherwise do something else.

I prefer not to ask the user for the current date and save it.

I tried many ways, but they do not work, I also tried to print the date (does not work):

{ "context": { "currdate": "@sys-date:today" }, "output": { "text": { "values": [ "here it is $currdate" ], "selection_policy": "sequential" } } } 
+5
source share
3 answers

I am not sure about this, but with all the checks that I tried, if the user does not enter today or something else, Watson will not recognize it, but, I believe, we can do something with the code. Someone working with IBM Watson will probably answer you correctly.

But in my basic knowledge:

Try using now () in a state and save the date inside the context variable.

Return:

 yyyy-MM-dd HH:mm:ss 

Use your code to get the context variable and get only the date ... after you can make conditions ...

JSON example:

 { "context": { "dateHour": "<? now() ?>" }, "output": { "text": { "values": [ "Now is $dateHour." ], "selection_policy": "sequential" } } } 

I study all the documentation about system objects in Watson and I don’t see anything about data retrieval if the user doesn’t request it, but as I say, maybe someone working at IBM will answer, I'm just trying to help you with my basic knowledge .

Check out the documentation for this project @sys-date now() here .

+7
source

It is to the right, you will need the application code to capture the current date and time and pass it as a context. So far, all of our system divisions and efforts have been around understanding what the user is saying, so if they don’t speak today, we won’t know what is important. Theoretically, I think you could just pass your application through “today” at the end of a user’s sentence or something like that and run it through the processing pipeline and give you today's date, but it can be a weird user interface.

+3
source

If you use now() , you can reformat it to make it work.

I save the date on which I want to compare it to $ date, in your case "date": "04-15-2017" , and then use the following:

To find out if this date will be used in the future: now().reformatDateTime('dd-MM-yyyy').before($date)

If past: now().reformatDateTime('dd-MM-yyyy').after($date)

Here you can read on reformatDateTime here . It uses the standard JAVA date string formatting rules that you can find here .

+1
source

Source: https://habr.com/ru/post/1266265/


All Articles