Watson Conversation Dialogue, how to save user input using slot

亡梦爱人 提交于 2019-12-06 04:58:09

If you want to save user input then you can use to save the input in any variable.

"context":{
"issue_description":"<?input.text?>"
}

To capture something like a description in a slot, my recommendation is to

  • define an entity based on a pattern that describes how the description should be.
  • in the pattern, you could use quotes as delimiter of the string to capture
  • in the slot definition Watson has to look for that entity, you provide the name of a context variable the entity value is saved to
  • access the context variable to process the captured value

There is a sample workspace I wrote that captures an event description using a pattern. In the dialog I cut the quotes off the string and then send it to a function for postprocessing. The eventName is defined as follows, the pattern in patterns is the interesting part:

{
      "entity": "eventName",
      "values": [
        {
          "type": "patterns",
          "value": "shortname",
          "created": "2018-01-31T13:28:56.245Z",
          "updated": "2018-02-07T09:08:31.651Z",
          "metadata": null,
          "patterns": [
            "[\"„“][A-Za-z0-9.:| @\\']+[\"”“]"
          ]
        }
      ],
}

To store the user input as in the context variable issue_description, you can either use an intent if you are not validating the input (description) or you can use an entity with the synonym value based on pattern. By doing this, you can configure the bot to recognize the condition and save the value to the context variable.

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