我用watson conversion创建了一个项目。流程是这样的:(对不起,我不能显示我的对话流程,但我会尝试解释它)
(W:Watson,U:User)
U:开户需要什么文件?W:姓名、电子邮件、联系人。我能为你打开它吗?U:好的W:太好了,请输入您的姓名。U: XYZ W: XYZ请输入您的联系电话。U: 9999999999 W: XYZ,您做得很好,请输入您的电子邮件。U: xyz@domain.com
now come to watson dialog part.
W:Great, Please enter your name.(i used " < ? input.text ?>" to take user input)
{
"context":{"name":"< ? input.text ?>"}
"output":{"text":"Great,Please enter your name."}
}
U:XYZ
W:XYZ please enter your contact number
{
"context":{"contact":"< ? input.text ?>"}
"output":{"text":"$name, Please enter your contact number"}
}
U:9999999999
W: XYZ, you are doing great please enter your email.
{
"context":{"email":"< ? input.text ?>"}
"output":{"text":"$name, you are doing great please enter your email."}
}
U: xyz@domain.com
这是我的流程,当我在watson中运行它时,它工作得很完美。但是当我试图从我自己的应用程序中运行它时,它只接受我的名字,而不是在循环中输入,这意味着它不会接受其他信息。
reason is in json it pass:
{
"text":"XYZ"
}
但沃森表明,这是无关紧要的意图。
在我的项目中,我只想将用户数据从我的应用程序传递到watson,它会显示如上所述的输出。
is it support < ? input.text ?>...?
发布于 2018-01-09 21:51:51
对于Watson Conversation给出意图的部分来说,这是因为您缺少将参数conversation_id作为上下文参数发送。
您将在响应中获得conversation_id,并在后续调用中传递它。如果不传递该参数,则每次都会生成一个新的id
//Extract converstaionId from first call
String conversationId=msgResponse.getContext().get("conversation_id")
//Second call in which user gives his name
Map contextData=new HashMap();
context.put("conversation_id", conversationId); // conversationId will be in the response of previous call
https://stackoverflow.com/questions/47330259
复制相似问题