我正在尝试在 Wit.ai 中的 Node.js 中定义多个动作编码,但出现错误 -
“[错误] [相反]错误:TypeError:无法读取未定义的属性'替换'”
有谁知道我为什么得到这个,以及定义多个动作的正确方法是什么?
谢谢!
const actions = {
say(sessionId, context, message, cb) {
console.log(message);
cb();
},
merge(sessionId, context, entities, message, cb) {
// Retrieve the location entity and store it into a context field
`enter code here`
const loc = firstEntityValue(entities, 'location');
if (loc) {
context.loc = loc;
}
cb(context);
},
error(sessionId, context, error) {
console.log(error.message);
},
['forecast-all'](sessionId, context, cb) {
// Here should go the api call, e.g.:
`enter code here`
context.forecast = getWeather(context.loc)
cb(context);
},
['forecast-feelslike'](sessionId, context, cb) {
// Here should go the api call, e.g.:
context.forecast = getFeelslike(context.loc)
cb(context);
},
};