Calling Now Assist Custom Skill from scripts with non-record related parameters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a use case where I need to call Now Assist custom skill from a request flow. I will need to pass not only the RITM details to the Now Assist custom skill, but also other data points collected from external system.
Reading the ServiceNow doc Call a custom skill from a script • Zurich Enable AI • Docs | ServiceNow, I wonder if queryString of inputsPayload can be used to pass these extra attributes? I wonder if there is any example of how queryString is being in the calling script and Now Skill? Is it possible to pass JSON object in the queryString?
I wonder if someone investigated this and has some learning to share?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
(function runScript(context) {
/* @Param {Object} context - Execution context, which may include:*/
/* - Previous tool outputs/inputs (e.g., context['ToolName.attributeName'] or context.getValue('ToolName.attributeName')).*/
/* - Additional context information (e.g., context.getAllValues()).*/
/* @returns {Object} - The computed value for the attribute.*/
var ritmSysId = context['requested_item'];
// Get all variables for this RITM
var variables = {};
var gr = new GlideRecord('sc_item_option');
gr.addQuery('request_item', ritmSysId);
gr.query();
while (gr.next()) {
var questionText = gr.item_option_new.question_text.toString();
var variableName = gr.item_option_new.name.toString();
var value = gr.value.toString();
var displayValue = gr.getDisplayValue('value');
variables[variableName] = {
question: questionText,
value: value,
displayValue: displayValue
};
}
return (JSON.stringify(variables, null, 2));
})(context);(function runScript(context) {
/* @Param {Object} context - Execution context, which may include:*/
/* - Previous tool outputs/inputs (e.g., context['ToolName.attributeName'] or context.getValue('ToolName.attributeName')).*/
/* - Additional context information (e.g., context.getAllValues()).*/
/* @returns {Object} - The computed value for the attribute.*/
try {
var request = new sn_ws.RESTMessageV2();
// Public endpoint: Fetching current temperature for Atlanta, GA
// No Auth required.
// Used as a sample endpoint.
request.setEndpoint('https://api.open-meteo.com/v1/forecast?latitude=33.749&longitude=-84.388¤t=temperature_2m');
request.setHttpMethod('GET');
var response = request.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
if (httpStatus === 200) {
// Parse the JSON string into a variable
var weatherData = JSON.parse(responseBody);
} else {
gs.error("API Error: " + httpStatus);
}
} catch (ex) {
gs.error("Exception: " + ex.message);
}
return weatherData;
})(context);