jsonibm-cloudibm-watsonwatson-conversation

How to extract current date in watson conversation


I need to create a condition, in Watson Conversation dialog model, like this:

if "today's date" < 04-15-2017 do something. else do something else.

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

I tried many ways but they don't work, I also tried to output the date (doesn't work):

{
  "context": {
    "currdate": "@sys-date:today"
  },
  "output": {
    "text": {
      "values": [
        "here it is $currdate"
      ],
      "selection_policy": "sequential"
    }
  }
} 

Solution

  • I'm not sure about that, but with all tests I've tried, if user dont type today or something, Watson dont recognize, but, I believe with code we can do something. Probably someone work with IBM Watson will answer you correctly.

    But, in my basic knowledge:

    Try use now() in condition and save the date inside context variable.

    The return is:

    yyyy-MM-dd HH:mm:ss
    

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

    JSON Example:

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

    I'm study all documentation about System entities within Watson and I dont see anything about extract the data if user dont request, but, how I say, probably someone work at IBM will answer, I'm just trying help you with my basic knowledge.

    Check the Documentation about this entitie @sys-date now() here.