2017-01-08 2 views
1

У меня есть несколько историй, но если я попробую типа что-то вроде blah, wit.ai используйте hello рассказ.как сделать историю «я не понимаю» в wit.ai

Но мне нужно что-то наподобие *wildcard рассказ с ответом I don't understant. Easy с witbot и intences, но я не знаю, как сделать в узел-остроумия и историй.

ответ

2

У меня была аналогичная проблема, и я решил настроить код 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' ; 
+0

Именно то, что я искал. :) –

Смежные вопросы