NLU Utterance Prediction Using Script
Import
·
Oct 10, 2023
·
article
Hi Experts,
In this article, I have added the code to get the NLU Prediction result based on our model and utterance.
Execute the below code in the background script to test :
try {
var modelId='<<Add you model sysID>>';//NLU Model sys_id
var utterance='coffee with prady';// add the utterance
if (modelId && utterance) {
var result = global.NLUStudioPredictor.testUtterance(modelId, utterance);
//gs.info(JSON.stringify(result));//print the result
if(result.status=='success'){
gs.info(result.message.intents[0].intentName);//Print the predicted Intent Name
gs.info(parseInt(result.message.intents[0].score)*100);//print the accuracy score in % wrt utterance
}
} else {
gs.info("Invalid input data provided");
}
} catch (e) {
gs.info('Error+++++++++ '+e);
}
Please mark this helpful if this helps you in any manner.
Thanks,
Pradyumna Das
View original source
https://www.servicenow.com/community/developer-articles/nlu-utterance-prediction-using-script/ta-p/2697876