У меня была аналогичная проблема, и я решил настроить код wit.js для вызова специального метода lowConfidence, если уверенность в следующем шаге ниже заданного порогового значения.
В моих остроумие действий файл:
// Setting up our wit client
const witClient = new Wit({
accessToken: WIT_TOKEN,
actions: witActions,
lowConfidenceThreshold: LOW_CONFIDENCE_THRESHOLD,
logger: new log.Logger(log.DEBUG)
});
и позже
lowConfidence({context}) {
console.log("lowConfidenceConversationResponse");
return new Promise(function(resolve) {
context.lowConfidence=true;
context.done=true;
// now create a low_confidence story in wit.ai
// and have the bot response triggered always
// when context.lowConfidence is set
return resolve(context);
});
}
И в wit.js
else if (json.type === 'action') {
let action = json.action;
// json.confidence is confidence of next step and NOT
// wit.ai intent identification confidence
const confidence = json.entities && json.entities.intent &&
Array.isArray(json.entities.intent) &&
json.entities.intent.length > 0 &&
json.entities.intent[0].confidence;
if (confidence && confidence<lowConfidenceThreshold)
action = 'lowConfidence' ;
Именно то, что я искал. :) –