简体   繁体   中英

How to make Watson Conversation Api Invoke a web Application Url when User Enters an Input?

我有一个spring mvc应用程序,我想让我的用户调用一个机器人,基于用户输入的机器人应该访问一个URL并根据响应提供答案。我怎样才能在Java中实现这一点?

There is no direct way to do it. However, Watson Conversation does provide a mechanism to handle such requests. You will need to tell the calling Java app that a url needs to be invoked.

This is done by using two features: Context.request skip_user_input

A request is a special context variable that has args, name and result. It is used to tell the calling app that it should do some action based on this variable.

Setting skip_user_input is optional. In many cases, you might want to execute some business logic in your application and then provide its results via result . Setting skip_user_input to true, will tell Watson Conversation to not wait for input from the user. Thus, your condition on the next node should be based on the content inside result .

{
  "output": {},
  "context": {
    "request": {
      "args": {
        "url_to_invoke": "your_url"
      },
      "name": "Call_A_URL",
      "result": "context.response"
    },
    "skip_user_input": true
  }
}

This feature is now available, with the help of IBM cloud functions. The link has the details of the implementation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM