我有一个 Watson Assistant 实例,我想用它来为我的站点用户提供计算服务。我遵循了此处的文档,该服务似乎正确地为每一位信息选择了插槽,并且我的客户端应用程序的方法也正确测试了。我不确定为什么我无法访问我的方法发送回节点的响应。
这是我的客户端方法:
function fraisCar(action){
if (action.puissance <= 3) {
if(action.kilometres <= 5000){
var bareme = action.kilometres * 0.41;
}
if(action.kilometres > 5000 && action.kilometres <= 20000){
var bareme = (action.kilometres * 0.245) + 824
}
if(action.kilometres > 20000){
var bareme = (action.kilometres * 0.286)
}
}
if (action.puissance == 4) {
if(action.kilometres <= 5000){
var bareme = action.kilometres * 0.493;
}
if(action.kilometres > 5000 && action.kilometres <= 20000){
var bareme = (action.kilometres * 0.277) + 1082
}
if(action.kilometres > 20000){
var bareme = (action.kilometres * 0.332)
}
}
if (action.puissance == 5) {
if(action.kilometres <= 5000){
var bareme = action.kilometres * 0.543;
}
if(action.kilometres > 5000 && action.kilometres <= 20000){
var bareme = (action.kilometres * 0.305) + 1188
}
if(action.kilometres > 20000){
var bareme = (action.kilometres * 0.364)
}
}
if (action.puissance == 5) {
if(action.kilometres <= 5000){
var bareme = action.kilometres * 0.543;
}
if(action.kilometres > 5000 && action.kilometres <= 20000){
var bareme = (action.kilometres * 0.305) + 1188
}
if(action.kilometres > 20000){
var bareme = (action.kilometres * 0.364)
}
}
if (action.puissance == 6) {
if(action.kilometres <= 5000){
var bareme = action.kilometres * 0.568;
}
if(action.kilometres > 5000 && action.kilometres <= 20000){
var bareme = (action.kilometres * 0.32) + 1244
}
if(action.kilometres > 20000){
var bareme = (action.kilometres * 0.382)
}
}
if (action.puissance > 6) {
if(action.kilometres <= 5000){
var bareme = action.kilometres * 0.595;
}
if(action.kilometres > 5000 && action.kilometres <= 20000){
var bareme = (action.kilometres * 0.337) + 1288
}
if(action.kilometres > 20000){
var bareme = (action.kilometres * 0.401)
}
}
var frais = bareme + action.fraisGarage + action.fraisPeage + action.fraisEmprunt;
return {frais: frais};
}
我尝试在执行操作后立即跳转到子节点,以防止在显示消息之前预期用户输入,使用 output.frais 等,但没有任何效果。
访问返回对象的值并将其自动嵌入到 Watson 响应中的最佳方式是什么?
如果我有更简单的计算,比如乘法,我该如何在对话节点中使用 java.lang.Math 类来做呢?我尝试了文档中的语法,但由于某种原因它并不完整。
注意:我不想使用 IBM Cloud Functions 执行服务器操作,只是一个客户端调用。