AntoniZ99967320
Kilo Sage

1. Why GenAI for Catalog Items and Record Producers?

Catalog Items and Record Producers are often the first touchpoint for employees and consumers. They collect structured inputs, trigger workflows, and create records - but they rarely understand the context behind the request.

 

With a Now Assist Custom Skill we can transform these forms into intelligent, context-aware experiences that:

  • Interpret user intent
  • Summarize long inputs
  • Generate tailored messages
  • Validate or enrich form data
  • Guide users through complex submissions

This article uses the Tailored SMS use case as a blueprint for building GenAI-enhanced Catalog Items and Record Producers.

 

2. The Use Case: Tailored SMS

Agents often need to send SMS messages during live calls or chats. The challenge:

  • The message must match the conversation
  • It must follow the correct template
  • It must be short, clear, and compliant
  • It must be generated in seconds, while the agent is still talking

This is a perfect GenAI use case.

 

AntoniZ99967320_0-1777843050581.png

 

3. Solution Architecture Overview

Below is the architecture pattern used for Tailored SMS and applicable to Catalog Items and Record Producers.

 

High-Level Architecture

User Input (Catalog Item / Record Producer)

        ↓

Client Script (trigger)

        ↓

Script Include (server call)

        ↓

Subflow (Execute Skill)

        ↓

Custom Skill (Tailored SMS)

        ↓

Generative AI Config (LLM)

        ↓

Response returned to UI

 

This architecture is modular, scalable, and reusable across any form.

 

AntoniZ99967320_3-1777845512577.gif

 

3. Now Assist Custom Skill: Tailored SMS

AntoniZ99967320_2-1777905561657.png

In Deployment and skill settings the Flow Action have to be set to "true".

 

AntoniZ99967320_1-1777905430866.png

 

4. Subflow: Tailored SMS > Execute Skill

The subflow Tailored SMS orchestrates the execution.

Flow Action (Excerpt)

AntoniZ99967320_0-1777905197661.png

 

 

5. Script Include: Server-Side Execution

The Script Include acts as the server-side bridge.

Script Include (Excerpt)

// function in the SMSRecProducerAjax client callable Script Include
tailoredSMS: function() {

        var countryId = this.getParameter('sysparm_country_id');
        var consumerID = this.getParameter('sysparm_consumer_id');
        var smsType = this.getParameter('sysparm_sms_type');
        var interactionID = this.getParameter('sysparm_interaction');

        // Call backend Script Include
        var backend = new SMSBackend();
        var smsText = backend.generateTailoredSMS(countryId, consumerID, smsType, interactionID);

        return smsText; // Return plain string
}

______________________________________________________________________
// the Script Include triggering the flow

var SMSBackend = Class.create();
SMSBackend.prototype = {
    initialize: function() {},

    generateTailoredSMS: function(marketId, consumerId, smsType, interactionId) {
        try {
            var grInteraction = new GlideRecord('interaction');
            grInteraction.get(interactionId);

            var inputs = {};
            inputs['transcript'] = grInteraction.transcript.toString();
            inputs['sms_type'] = smsType;
            inputs['language'] = 'English';

            // Execute and wait for completion + retrieve outputs
            var outputs = sn_fd.FlowAPI.executeSubflow('sn_csm_gen_ai.tailored_sms', inputs);
			
            // Extract SMS text
            var smsText = outputs['sms_preview'];
			
            return smsText;

        } catch (ex) {
            gs.error("Tailored SMS Error: " + ex.getMessage());
            return '';
        }
    },

    type: 'SMSBackend'
};

 

6. Client Script: Triggering the Generation

A simple onChange Client script can call the Script Include via GlideAjax.

Client Script (Excerpt)

function onChange(control, oldValue, newValue, isLoading) {

    var consumerID = g_form.getValue('consumer');
    var smsType = g_form.getValue('sms_type');
    var countryID = g_form.getValue('country');
    var interactionID = g_form.getValue('source_interaction');
    var sysparmName = (smsType == 'tailored_sms') ? 'tailoredSMS' : 'checkTemplates';

    var ga = new GlideAjax('SMSRecProducerAjax');
    ga.addParam('sysparm_name', sysparmName);
    ga.addParam('sysparm_consumer_id', consumerID);
    ga.addParam('sysparm_sms_type', smsType);
    ga.addParam('sysparm_country_id', countrytID);
    ga.addParam('sysparm_interaction', interactionID);

    ga.getXMLAnswer(function(response) {

        if (smsType == 'tailored_sms') {
			
			g_form.setMandatory('sms_template',false);
			g_form.setVisible('sms_template',false);
			
			g_form.setValue('sms_preview', response);
			g_form.setReadOnly('sms_preview',false);
			g_form.setMandatory('sms_preview',true);
			g_form.addDecoration('sms_preview', 'icon-ai-sparkle-fill', 'AI','color-green');
			g_form.showFieldMsg('sms_preview',"This is AI generated text. Please, review before sending!",'warning');
			
        }
    });
}

 

7. Applying This Pattern to Catalog Items/Record Producers

Example Variables

Variable

Type

Maps to

sms_type

Choice

action / intent

sms_template

Reference

sms_template

language

Choice

language

sms_preview

String

AI output

 

AntoniZ99967320_1-1777844576434.png

 

 

8. Final Thoughts

The Tailored SMS solution demonstrates a powerful pattern:

  • Any Catalog Item or Record Producer can become GenAI-enhanced with only a client script, a Script Include, and a Flow that executes a Now Assist Custom Skill.
  • This architecture is clean, scalable, and fully aligned with ServiceNow best practices.

 

Additional Documentation:

Version history
Last update:
Monday
Updated by:
Contributors