我會寫使用node-wit
1)建立和應用程序文件夾中的示例步驟,去它並運行:npm init
const {Wit, log, config} = require('node-wit');
const client = new Wit({accessToken: 'MY_TOKEN'});
4)從documentation:)運行npm i --save node-wit
3)app.js
個
runActions
更高級別的方法將威特相反的API。 runActions會重置 ,最後打開新的消息和錯誤。
採用下列參數:
sessionId - a unique identifier describing the user session
message - the text received from the user
context - the object representing the session state
maxSteps - (optional) the maximum number of actions to execute (defaults to 5)
,我得加MAX_STEPS
示例有:
const MAX_STEPS = 25;
const sessionId = 'some-session-id';
const context0 = {};
client
.runActions(sessionId, 'events nearby', context0, MAX_STEPS)
.then((context1) => {
return client.runActions(sessionId, 'how about in London?', context1, MAX_STEPS - 1);
})
.then((context2) => {
console.log('The session state is now: ' + JSON.stringify(context2));
})
.catch((e) => {
console.log('Oops! Got an error: ' + e);
});
是應用程式位於第二屏幕截圖? – num8er