Search code examples
ibm-watsonwatson-conversation

How make Watson conversation recognize the time?


In the case I'm trying to see if it is possible or if there is a way to make Watson recognize the period according to the time.

  • If the conversation_start By night time Watson say: Good evening!
  • If the conversation_start By morning time Watson say: Good morning!
  • If the conversation_start By afternoon time Watson say: Good afternoon!

Actually I create one entitie with @time and if user type good night, the entities save that and Watson responds Exactly what the user typed.

And my response condition is:

 @time, how are you?

Example:

  • User: Good night!
  • Watson: Good night!, how are you

See that it was the same answer, because I created an entity with these periods

Check image:

enter image description here

I want to knows If it is possible to do it automatically or if I have to develop some code to do this, and if possible an example.


Solution

  • As specified here you can use now()

    see

    {
      "conditions": "now().before('12:00:00')",
      "output": {
        "text": {
          "values": [ "Good morning!" ]
          }
       }
    }
    

    Per @MichalBida comment, pls note that now() does not record the time on the end user channel but rather of the conversation service. A better approach is therefore to provide a context variable with the time on the end user time zone and on it apply .before('12:00:00')