Exploring the Invocation Graph within ServiceNow’s GenAI Controller

Nicola Attico
2 min readMar 13, 2024

In the realm of ServiceNow applications, it becomes evident that data models, though comprehensive, do not encapsulate the entirety of the platform’s capabilities. A crucial component of understanding these applications lies within their process dimension, specifically through invocation graphs.

The invocation graph also called the call graph, is a pivotal tool for understanding the connectivity of an application’s process elements. Within the Now Platform, the GenAI Controller and its corresponding GenAI Spokes present a prime opportunity to leverage the invocation graph. This graph meticulously outlines the complex sequence of invocations, starting from the controller and progressing to the Flow Designer script, which includes APIs and culminates in the data model.

Achieving a deep understanding of the GenAI controller is instrumental for comprehending its operations and customizing its behavior to meet specific customer needs.

Key Insights from the GenAI Controller Invocation Graph:

  1. The Generate Content activity initiates the process, acting as the primary trigger.
  2. The system operates in two significant modes: Tokyo (≤T) and Utah (≥U), with Tokyo mode serving as a default fallback.
  3. The Chat Completion step within the Flow Designer is responsible for making the actual REST call to the provider API, specifically targeting OpenAPI’s /v1/chat/completions endpoint.
  4. The invocation graph provides a detailed overview of the call flow within both pre-processor and post-processor script includes.
  5. Prompt generation takes place within the _createPrompt method, relying on the Generative AI Configurations table for setting parameters such as model, temperature, and max_tokens.
  6. Request and response validation are conducted during the pre-processing and post-processing stages, ensuring integrity and accuracy.

Color/Shape Coding for Easier Interpretation:

  • Scopes are depicted in light blue.
  • Plugins are represented in purple.
  • Properties are highlighted in yellow.
  • Tables are shown in green.
  • Script includes are indicated in orange, with dark orange specifically denoting Java classes.
  • Script of FD Objects is presented in white.
  • Function calls are illustrated with dashed arrows.
  • Direct access to the data model, properties, and plugins is represented with solid arrows.

A high-resolution version of this diagram is available for download here. It offers a comprehensive visual aid for those interested in delving deeper into the GenAI Controller’s functionality.

This exploration into the invocation graph underscores the intricacies of process connectivity within ServiceNow applications and highlights the importance of the GenAI Controller in navigating and customizing these processes.

Note: While automating data model diagrams can be straightforward, creating invocation diagrams presents a more complex challenge. It necessitates parsing Flow Designer data and JavaScript Abstract Syntax Trees (ASTs) to depict the sequence of processes and their interconnections accurately.

--

--