First question falling into intent === none but asking it a second time always works

Hi again,

Struggling with something these days, after having spent so much time figuring out everything, now I have a weir behaviour.

When writing a question, even if there are 2 possible top intents, I see in the log that the bot sees no intent and falls down into the intent === none flow instead of going to the top intent.

But it’s funny, because if I ask exactly the same question again, then it answer correctly, also if I reinitiate the bot, the behaviour is correct.

It happens from time to time, but not always, here there’s a video showing the problem, basically doing exactly the same, asking the same question first I get this:

And if I ask the same question after that I get this:

2021-11-02 17:55:55debugbp:dialog (pio) [12fim_bXoQHa-3YdUSoACNkl] transit (buyer.flow.json) [FAQ] -> [ask]{ botId: 'pio' }, +5ms
2021-11-02 17:55:55debugbp:dialog (pio) [12fim_bXoQHa-3YdUSoACNkl] render element "#!builtin_text-YvYfu1"{ botId: 'pio' }, +4ms
2021-11-02 17:55:55debugbp:dialog (pio) [12fim_bXoQHa-3YdUSoACNkl] waiting until next event{ botId: 'pio' }, +5ms
2021-11-02 17:56:02debugbp:dialog (pio) [12fim_bXoQHa-3YdUSoACNkl] eval transition "event.nlu.intent.name === 'none'" to [doubts]{ botId: 'pio' }, +7s
2021-11-02 17:56:02debugbp:dialog (pio) [12fim_bXoQHa-3YdUSoACNkl] transit (buyer.flow.json) [ask] -> [doubts]{ botId: 'pio' }, +7s

I have a module that might interfere:

function hook(
  bp: typeof sdk,
  sessionId: string,
  event: sdk.IO.IncomingEvent,
  suggestions: sdk.IO.Suggestion[]
) {
  /** Your code starts below */

   if ((!suggestions.length || !suggestions[0].decision) & !event.nlu.intents[0]) {
    if (!suggestions.length) {
      bp.logger.info('### Hook can not find an answer 1 ###')
      return
    }
    if (!suggestions[0].decision) {
      bp.logger.info('### Hook can not find an answer 2 ###')
      return
    }
  }
    
  if (
    //event.state.context.currentFlow === 'buyer.flow.json' &&
    event.state.context.currentNode === 'ask' &&
    suggestions[0].decision.status === 'dropped' && //check if qna was sidelined
    //suggestions[0].confidence > 0.85 && //check if confidence is higher than what you perceive as in this case 85%minimal
    suggestions[0].decision.reason.includes('would have been elected, but already in the middle of a flow') // check if drop reason is because we are in a flow
  ) {
    // Now messing with the decision status and changing it to elected then giving a diplomatic reason for the dude who reads the logs (Hit Me)

    bp.logger.info('Hook detected matching QnA')
    suggestions[0].decision.status = 'elected'
    suggestions[0].decision.reason = 'Elect a QnA at high confidence during a flow'
  }

  /** Your code ends here */
}

Hi @Tronne, I hope you are keeping well.

Before Botpress 12, you could configure a minimum threshold for intents ( confidenceTreshold ). By so doing, you would be able to change the pre-defined default, and an environment variable quickly did this in .env. Now you need to create a before_suggestions_election hook which

  1. Checks the predicted intent’s confidence.
  2. Alters the event payload (i.e. change the suggestions confidence to 1, so the decision engine picks it up)

@Michael_BotpressTeam as usual, thank you very much for the answer, but that doesn’t explain why the second time works perfectly or why when reinitiated the bot works correctly.

I think the solution is more about some timeout that leave the NLU inactive for the first run, In some other post I’ve read something about a lazy run for a similar behaviour.

So my theory is that once the NLU is loaded then everyhting works smooth but when you leave it idle some time it enters into timeout, deactivate NLU till for some reason after the second same question it runs again.

It makes sense in my mind but I might be hallucinating.

If it happens that I’m right how can I reactivate the NLU with a hook or something?

Thanks

Hie @Tronne.

Let me engage the NLU team to find if there is a fix for this on the cards. If not, I will open a Github issue so that the bug is investigated and fixed.

Thank you @Michael_BotpressTeam any update?

1 Like

I have the same problem, I thought that was my error, somehow.

@Tronne Do you use botpress’s default language server?

@magicofspade yes, we use the default, do you think it might have relation? I think its about timeout / lazy run

We had the same issue, it’s resolved when we switched to self hosted language server.

1 Like