QnA does not intercept

Hi, I am unsure how to enable interception of the flow to the right QnA answer. QnA does detect the question but it says it drops the answer due to being in the middle of a flow. How do I make it such that it will go straight to answering? Thank you in advance for any help!

image

That means the bot was waiting for an answer but you triggered a QNA question. Can you take a screenshot of your conversation so I can better understand your flow?

Thank you for the response!

I have attached a screenshot of the flow. After asking the question in the first node, the bot responds with the choice. If the user answers with an already defined question (“who is the ceo” in this case), the bot drops the suggestion although it detects the question and goes to the failure node. I would like it to just respond with the answer instead.

Edit: Update with clearer example of issue

Sorry to disturb but @rndlaine any ideas? Thanks!

Yeah in this case the Decision Engine decided to drop the QnA because you are in the middle of a flow. Currently the best way to work around this would be to modify the Election by using a hook.

BEFORE

AFTER


Solution

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

  async function hook() {
    bp.logger.info('Before election', suggestions)
    if (!suggestions.length || !suggestions[0].decision) {
      return
    }

    const decision = suggestions[0].decision
    if (decision.status === 'dropped' && decision.reason.includes('already in the middle of a flow')) {
      // We're fiddling with the election results
      decision.status = 'elected'
      decision.reason = 'we tricked election results from the hooks'
    }
  }

  return hook()
  /** Your code ends here */
}
1 Like