2016-11-16 3 views
0

何らかの理由で、私はチャットボットのデフォルトの最大ステップ数を増やすことができません。Wit.aiデフォルトの最大ステップを変更する

これは以前のようにlib/config.jsではなくlib/wit.jsで定義されているようです。私の設定ファイルのDEFAULT_MAX_STEPS定数を何に変更しても、ボットがいくつかの応答を送信するようにするには、私のログに「Max steps reached、stopped」エラーが表示される前に同じ制限(5)行為のいくつか。

私は/ libにサンプルプロジェクトがwit.jsにリンクしているようだと、ノード・ウィットを経由してモジュール内のファイルをlog.js同様のファイルをリンクしようとした

設定ファイル:

enter image description here

私が想定している:私は私のindex.jsファイルにリンクしようとした方法

enter image description here

私はnode-wit

1)を作成し、アプリのフォルダを使用する例の手順を書きます

+0

? – num8er

答えて

1

私は... config.jsのが適切にファイルを参照していないよ、それに移動して実行します。npm init

2 )npm i --save node-wit

3)app.js実行:

const {Wit, log, config} = require('node-wit'); 
const client = new Wit({accessToken: 'MY_TOKEN'}); 

4)documentationから:

runActions

ウィット逆APIの高レベルの方法。 runActionsは、最後に新しいメッセージとエラーが発生したときに をリセットします。私はそこ例にMAX_STEPSを追加します

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) 

は、次のパラメータを取りアプリが第二のスクリーンショットに位置

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

関連する問題