如何在用户输入输入时使Watson Conversation Api调用Web应用程序URL? [英] How to make Watson Conversation Api Invoke a web Application Url when User Enters an Input?
问题描述
我有一个spring mvc应用程序,我想让我的用户调用一个bot,而基于用户输入的bot应该访问一个url并根据响应提供一个答案。我怎么能用Java实现这个?
I have a spring mvc application and I would like to make my user call a bot and the bot based on user input should access a url and based on the response provide an answer.How could I achieve this in Java?
推荐答案
没有直接的方法可以做到这一点。但是,Watson Conversation确实提供了处理此类请求的机制。
您需要告诉调用Java应用程序需要调用url。
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.
这是通过使用两个功能完成的:
Context。请求
skip_user_input
This is done by using two features: Context.request skip_user_input
请求
是一个具有args,name和result的特殊上下文变量。
它用于告诉调用应用程序它应该根据此变量执行某些操作。
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.
设置 skip_user_input
是可选的。在许多情况下,您可能希望在应用程序中执行某些业务逻辑,然后通过 result
提供其结果。将 skip_user_input
设置为true,将告诉Watson Conversation不等待来自用户的输入。因此,您在下一个节点上的条件应该基于结果
中的内容。
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
}
}
这篇关于如何在用户输入输入时使Watson Conversation Api调用Web应用程序URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!