Skip to main content
Version: 4.5.0

Function: AiAgenticWorkflow(config)

Creates an AI Agentic Workflow that defines dynamic behavior for agentic workflows

Parameters

config

AiAgenticWorkflow

Properties:

  • $id (required): string | number | ExplicitKey<string>

  • description (required): string Description of the AI Agentic Workflow

  • name (required): string The display name of the AI Agentic Workflow

  • acl (optional): string | Record<'sys_security_acl'> | Acl<unknown, AclType> ACL reference (sys_id, Record, or Acl object defined in Fluent)

  • active (optional): boolean Whether the workflow is active

  • contextProcessingScript (optional): string | (task: any, user_utterance: any, workflow_id: any, context: any, dependencies: any[]) => any Context processing script for the workflow - supports inline scripts or Now.include() for external files

  • dataAccess (optional): DataAccessConfigWorkflowType

  • executionMode (optional): ExecutionMode Execution mode (tools override) - choices: copilot or autopilot

  • memoryScope (optional): string Memory scope for team members

  • recordType (optional): RecordType Record type for the workflow

  • runAs (optional): string Data access controls (Dynamic User identity type). Can be empty/omitted when runAsUser is set.

  • sysDomain (optional): string Domain ID

  • team (optional): TeamType Team configuration

  • triggerConfig (optional): TriggerConfigType[]

    • channel: string Reference to Messaging Channel - defaults to Now Assist Panel. Use string value: "Now Assist Panel"

    • name: string Name of the trigger

    • active: boolean Active status - defaults to false

    • businessRule: string | Record<'sys_script'> | BusinessRule<unknown> Reference to Business Rule (sys_id, Record<'sys_script'>, or BusinessRule)

    • description: string Description of the trigger

    • domain: string Domain ID

    • enableDiscovery: boolean Enable discovery flag - defaults to FALSE

    • notificationScript: string | Record<'sys_script_client'> | ClientScriptProps<unknown, client_script_events, boolean> Reference to Client Script for notifications

    • objectiveTemplate: string Objective template

    • portal: string | Record<'now_assist_deployment_channel'> Reference to Now Assist Deployment Channel (sys_id or Record<'now_assist_deployment_channel'>)

    • profile: string | Record<'now_assist_deployment'> Reference to Now Assist Deployment (sys_id or Record<'now_assist_deployment'>)

    • runAs: string Run as field name

    • runAsScript: string | (current: any, dependencies: any[]) => string Run as script - supports inline scripts or Now.include() for external files

    • runAsUser: string | Record<'sys_user'> Reference to User who runs the trigger (user sys_id or Record<'sys_user'>)

    • schedule: ScheduleConfigWorkflowType Schedule configuration - used for scheduled triggers (scheduled, daily, weekly, monthly)

    • showNotifications: boolean Show notifications flag

    • sysOverrides: string | Record<'sn_aia_trigger_agent_usecase_m2m'> Reference to override the trigger-agent-usecase mapping (sn_aia_trigger_agent_usecase_m2m)

    • targetTable: unknown Target table name (Table Name)

    • triggerCondition: string Conditions for the trigger

    • triggerFlowDefinitionType: TriggerFlowDefinition Trigger flow definition type - choices: record_create, record_create_or_update, record_update, email, scheduled, daily, weekly, monthly

  • versions (optional): AIAVersion[]

    • name: string Version name (Translated Text)

    • condition: string Condition (Condition String)

    • instructions: string Instructions (Translated Text)

    • number: number Version number (Integer)

    • state: State

Examples

Basic AiAgenticWorkflow Example

A minimal AI Agentic Workflow definition with the required fields:

import { AiAgenticWorkflow } from "@servicenow/sdk/core";

/**
* @title Basic AiAgenticWorkflow Example
* @description A minimal AI Agentic Workflow definition with the required fields:
* name, description, and acl.
*/
export const basicWorkflow = AiAgenticWorkflow({
name: "Basic Support Workflow",
description:
"A simple agentic workflow that coordinates agents for support tasks",
acl: "itil",
});

Workflow with Scheduled Triggers

import { AiAgenticWorkflow } from "@servicenow/sdk/core";

/**
* @title Workflow with Scheduled Triggers
*/
AiAgenticWorkflow({
name: "Scheduled Review Workflow",
description: "Workflow that runs on a schedule",
acl: "",
runAs: "user_sys_id",
team: {
$id: Now.ID["scheduled_team"],
members: ["6816f79cc0a8016401c5a33be04be441"],
},
triggerConfig: [
{
name: "Weekly Review",
targetTable: "incident",
triggerFlowDefinitionType: "scheduled",
objectiveTemplate: "Review all incidents for the week",
channel: "Now Assist Panel",
schedule: {
runDayOfWeek: 2, // Monday
time: "1970-01-01 09:00:00", // 9:00 AM
triggerStrategy: "every",
},
},
{
name: "Monthly Report",
targetTable: "incident",
triggerFlowDefinitionType: "scheduled",
objectiveTemplate: "Generate monthly incident report",
channel: "Now Assist Panel",
schedule: {
runDayOfMonth: 1, // First day of month
time: "1970-01-01 08:00:00", // 8:00 AM
repeatInterval: "1970-01-05 12:00:00",
},
},
],
});

Workflow with Dynamic User Identity

import { AiAgenticWorkflow } from "@servicenow/sdk/core";

/**
* @title Workflow with Dynamic User Identity
*/
AiAgenticWorkflow({
name: "Dynamic Workflow",
description: "Workflow with dynamic user identity",
acl: "",
// runAs is omitted — dynamic user identity
team: {
$id: Now.ID["dynamic_team"],
members: ["agent_sys_id_1"],
},
versions: [{ name: "V1", number: 1 }],
dataAccess: {
roleList: ["itil_role_sys_id"], // MANDATORY when runAs is omitted
},
});

Simple Workflow with Fixed User

import { AiAgenticWorkflow } from "@servicenow/sdk/core";

/**
* @title Simple Workflow with Fixed User
*/
AiAgenticWorkflow({
name: "Simple Workflow",
description: "Basic workflow with fixed user",
acl: "",
runAs: "62826bf03710200044e0bfc8bcbe5df1", // Specific user
team: {
$id: Now.ID["simple_team"],
members: ["agent_sys_id_1"],
},
versions: [{ name: "V1", number: 1 }],
// dataAccess is omitted — not needed when runAs is set
});

Workflow with triggers

import { AiAgenticWorkflow } from "@servicenow/sdk/core";

/**
* @title Workflow with triggers
*/
AiAgenticWorkflow({
name: "Triggered Workflow",
description: "Workflow with automatic triggers",
acl: "",
runAs: "user_sys_id",
team: {
$id: Now.ID["triggered_team"],
members: ["agent_sys_id_1"],
},
triggerConfig: [
{
name: "Record Trigger",
targetTable: "incident",
triggerFlowDefinitionType: "record_create",
triggerCondition: "priority=1",
objectiveTemplate: "Process incident ${number}",
channel: "Now Assist Panel",
},
],
});