2016-11-16 55 views
0

出於某種原因,我無法增加我的聊天bot的默認最大步數。更改Wit.ai默認最大步驟

看起來這個數字現在在lib/config.js中定義,而不是像以前那樣在lib/wit.js中定義。不管我在我的配置文件中更改DEFAULT_MAX_STEPS常量,我的機器人似乎在達到相同的限制(5)之前,在我想讓機器人發送幾個響應/執行時,拋出「達到最大步數,停止」錯誤連續執行一些操作。

我已經試過了文件鏈接相同的方式,例如項目似乎鏈接到wit.js並通過節點機智log.js模塊中的文件/ lib中

配置文件:

enter image description here

如何我試圖將其鏈接到我的index.js文件:

enter image description here

我假設我不引用config.js文件正確...

+0

是應用程式位於第二屏幕截圖? – num8er

回答

1

我會寫使用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); 
    }); 
+1

爲了澄清,我的應用程序設置正確(不在包文件夾內),Wit工程師以前建議通過修改軟件包文件來修改默認的最大步驟 - https://github.com/wit-ai/node-wit/issues/65 您的解決方案雖然爲我工作,但謝謝! – wanstan

+0

很高興我的回答很有用(: – num8er

+1

@wanstan,fyi https://github.com/wit-ai/node-wit/pull/107 – num8er