Documentation - v1.2.0-alpha.3
    Preparing search index...
    • Finds the intent with the highest confidence score from a recognizer result.

      Parameters

      • result: RecognizerResult

        The recognizer result containing intents and their scores

      Returns { intent: string; score: number }

      An object containing the top-scoring intent name and its confidence score

      Throws an error if the result is empty or doesn't contain intents

      This function iterates through all intents in the recognizer result and returns the intent name and score for the intent with the highest confidence score. If multiple intents have the same highest score, the last one encountered is returned.

      const result: RecognizerResult = {
      text: "Book a flight to Seattle",
      intents: {
      "BookFlight": { score: 0.95 },
      "Cancel": { score: 0.02 },
      "Help": { score: 0.03 }
      }
      };

      const topIntent = getTopScoringIntent(result);
      // Returns: { intent: "BookFlight", score: 0.95 }