How do i extract the original date value passed from the user input

徘徊边缘 提交于 2019-12-11 06:28:36

问题


Context: The Watson Conversation bot has a node that gets triggered by three input entities from the user, this works fine, but i want the reply from the bot to be

"Checking if you have a lecture tomorrow. Give me a moment"

then there's a query in the background building up the answer that gets replied later to the user.

the strong word tomorrow is an @sys-date entity, but i want it to reply to the user what he/she said instead of the date, because the bot can check no both weeks months ect, all valid date formats, and the reply would look much better if i could use the original text from the user.

This kind of origin retrieval will be used for other entities aswell when i get it working.


回答1:


You can use the context variable in the case, and if you want to get specific data, you can use regex to extract the user input:

Example all user input

"date": "<? input.text?>"

or for exactly what the user input, ex: "this week"

 "date": "<?@sys-date.literal?>"

Etc..

Use the variable with the .literal, see my complete example:

        {
  "context": {
    "date": "<?@sys-date.literal?>"
  },
  "output": {
    "text": {
      "values": [
        "Checking if you have a lecture $date. Give me a moment."
      ],
      "selection_policy": "sequential"
    }
  }
}

Documentation examples :



来源:https://stackoverflow.com/questions/41891340/how-do-i-extract-the-original-date-value-passed-from-the-user-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!