how to make 'i dont understant' story in wit.ai

327 Views Asked by At

I have few stories but if I try type something like blah, wit.ai use hello story.

But I need something like *wildcard story with reply I don't understant. Easy with witbot and intences, but I don't know how to make in node-wit and stories.

1

There are 1 best solutions below

1
On BEST ANSWER

I had a similar problem and decided to tweak wit.js code to call a special lowConfidence method if the confidence for the next step is lower than a pre-defined threshold I set.

In my wit actions file :

// Setting up our wit client
const witClient = new Wit({
  accessToken: WIT_TOKEN,
  actions: witActions,
  lowConfidenceThreshold: LOW_CONFIDENCE_THRESHOLD,
  logger: new log.Logger(log.DEBUG)
});

and later

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);
      });
  }

And in 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'  ;