Is there a way to check the confidence of Wit.ai intent response?

110 views Asked by At

Im trying to check the confidence of my API response within my HTML page. If confidence is 0 {Go to this page} If confidence is 1 {Go to this page} I can check other things but not the intent confidence how would i do this?

fetch(`https://api.wit.ai/message?q=${transcript}`,
{
    headers: {
        Authorization: `Bearer ${token}`,
        'Content-Type': 'application/json',
    },
}).then(res => res.json())
.then(function (data){
    if (data.intents[0].value==[0]) {
        console.log("intent 1")
        //throw "Error";
    }
    else if (data.text==="pay"){
        console.log("works")
    }
    else {
        if(data.intents==="checkout"){
            console.log("intent 2");
        }
    }
})
1

There are 1 answers

0
Bcf Ant On

The intents property is an array of objects.

You can access the confidence score with the following;

data.intents[0].confidence