我正在关注此处的 Facebook Bot for Messenger First App 教程: https ://wit.ai/docs/quickstart
情况是,在克隆项目(https://github.com/wit-ai/node-wit.git)并按照第一步后,当我运行机器人时,我收到此错误:firstEntityValue is not defined
我的代码:
'use strict';
const Wit = require('../').Wit;
const token = (() => {
if (process.argv.length !== 3) {
console.log('usage: node examples/weather.js <wit-token>');
process.exit(1);
}
return process.argv[2];
})();
const actions = {
say: (sessionId, msg, cb) => {
console.log(msg);
cb();
},
merge: (context, entities, cb) => {
//Retrieve the location entity and store it into a context field
const loc = firstEntityValue(entities, 'location');
if(loc) {
context.loc = loc;
}
cb(context);
},
error: (sessionId, msg) => {
console.log('Oops, I don\'t know what to do.');
},
'fetch-forecast': (context, cb) => {
// Here should go the api call, e.g.:
// context.forecast = apiCall(context.location)
context.forecast = 'cloudy';
cb(context);
},
};
const client = new Wit(token, actions);
client.interactive();
有什么帮助吗?