Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Are all NLU nodes supported in LLM for Virtual Agent?

MayrelCerero
Tera Expert

We used the migration tool to transfer our NLU topics and topic blocks, but I am encountering loops or virtual agent conversations ending with a specific topic block. Does this indicate that some NLU nodes converted to LLM nodes are not supported? For instance, I have a dynamic choice input (refer to the screenshot) that was converted, but I am unable to determine the cause of the issues. The script under the NLU topic previously used gs.log, which I changed to gs.info, making me question if this node is unsupported. The script in this node is for a REST API call that allows users to reset their passwords.

(function execute() {
    var token = null;
    var options = [];
    var loginStatus = '';
    var getAccountStatus = '';
    var bodyJSON;
    var interaction;
    var restMess;

    try{
        //Set clockid to the confirmed clockid value
        var clockid = vaInputs.confirm_employee_id.getValue();
        
        //Get Interaction number for logging from the interaction table
        var imsGr = new GlideRecord('interaction');
        if(imsGr.get(vaVars._interaction_record_sysid)){
            interaction = imsGr.getValue('number');
        }else{
            interaction = "9999999999";
        };

        //Reference rest message by name, some settings found on rest message
        restMess = 'va_VoiceApi_Login'
        var execLoginAPI = new sn_ws.RESTMessageV2("va_VoiceApi_Login","POST");
        var reqBody = {
            type: "chat",
            interactionId: interaction,
        };
        
        //Add Logging to backend ServiceNow Logs
        gs.info("NASH API: "+interaction+" REST MESSAGE - "+restMess+" [NN Password Automated Assistance - getIseriesAccount] - REQ BODY: "+JSON.stringify(reqBody));

        //Set body for request
        execLoginAPI.setRequestBody(JSON.stringify(reqBody));
        //Call API Endpoint
        var response = execLoginAPI.execute();
        var responseBody = response.getBody();
        loginStatus = response.getStatusCode();
        if(loginStatus == 200)
        {
            bodyJSON = JSON.parse(responseBody); //Can't do this unless we have 200 code back, because we can't always expect a json body response
            token = bodyJSON.token;
        }else{
            vaVars.reset_success = 'false'
        }

        //Add response logging
        gs.info("NASH API: "+interaction+" REST MESSAGE - "+restMess+" [NN Password Automated Assistance - getIseriesAccount] - API Status Code: "+loginStatus+" RESPONSE BODY: "+JSON.stringify(responseBody));
        
        //Log token value for validation
        gs.info("NASH API: "+interaction+" REST MESSAGE - "+restMess+" [NN Password Automated Assistance - getIseriesAccount] - TOKEN: "+token);

        //If the auth token exists, proceed with the data call
        if(loginStatus == 200)
        {
            //Reference rest message by name, some settings found on rest message
            restMess = 'va_VoiceApi_iseries_account';
            var execAPI = new sn_ws.RESTMessageV2("va_VoiceApi_iseries_account","POST");
            //Set the request header to include the authentication info
            execAPI.setRequestHeader('auth',token);
            var reqBody = {
                clockId: clockid,
                type:"chat",
                interactionId: interaction
            };
            
            //Add Logging to backend ServiceNow Logs
            gs.info("NASH API: "+interaction+" REST MESSAGE - "+restMess+" [NN Password Automated Assistance - getIseriesAccount] - REQ BODY: "+JSON.stringify(reqBody));
            
            execAPI.setRequestBody(JSON.stringify(reqBody));            
            var apiResponse = execAPI.execute();
            var apiResponseBody = apiResponse.getBody();
            getAccountStatus = apiResponse.getStatusCode();

            //Add response logging
            gs.info("NASH API: "+interaction+" REST MESSAGE - "+restMess+" [NN Password Automated Assistance - getIseriesAccount] - API Status Code: "+getAccountStatus+" RESPONSE BODY: "+JSON.stringify(apiResponseBody));
            
            //Create user button display from API array response
            if(getAccountStatus == 200)
            {
                var account = JSON.parse(apiResponseBody);
                if(account.length > 0){
                    for(i=0; i < account.length; i++){
                        var user = account[i].user + " - " + account[i].part
                        options.push({ 
                            'value': account[i].part,
                            'label': user, 
                            'render_style': 'data' 
                        });
                    };
    
                    options.push({ 
                        'value': "ALL",
                        'label': "All Systems", 
                        'render_style': 'data' 
                    });
    
                    options.push({ 
                        'value': "skip",
                        'label': "Skip", 
                        'render_style': 'data' 
                    });
                }else{
                    vaVars.reset_success = 'false'
                };
            }else{
                vaVars.reset_success = 'false'
                gs.info("NASH ERROR: "+interaction+" REST MESSAGE - "+restMess+" [NN Password Automated Assistance - getIseriesAccount] Unable to retrieve user accounts");
            };
        }else{
            vaVars.reset_success = 'false';
            gs.info("NASH ERROR: "+interaction+" REST MESSAGE - "+restMess+" [NN Password Automated Assistance - getIseriesAccount] Authentication failed while attempting to get token");
        };
    }catch(err){
        vaVars.reset_success = 'false';
        //Add Logging to backend ServiceNow Logs
        gs.info("NASH ERROR: "+interaction+" REST MESSAGE - "+restMess+" [NN Password Automated Assistance - getIseriesAccount] API Status Code: LoginStatus -"+loginStatus+" API Status Code: getAccountStatus - "+getAccountStatus+"  Token:"+token+" ERROR: "+err);
        gs.info("NASH ERROR: "+interaction+" - getIseriesAccount ERROR: "+err);
    };
    return options;
})()

 

0 REPLIES 0