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):
stringDescription of the AI Agentic Workflow -
name (required):
stringThe 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):
booleanWhether the workflow is active -
contextProcessingScript (optional):
string | (task: any, user_utterance: any, workflow_id: any, context: any, dependencies: any[]) => anyContext processing script for the workflow - supports inline scripts or Now.include() for external files -
dataAccess (optional):
DataAccessConfigWorkflowType -
executionMode (optional):
ExecutionModeExecution mode (tools override) - choices: copilot or autopilot -
memoryScope (optional):
stringMemory scope for team members -
recordType (optional):
RecordTypeRecord type for the workflow -
runAs (optional):
stringData access controls (Dynamic User identity type). Can be empty/omitted when runAsUser is set. -
sysDomain (optional):
stringDomain ID -
team (optional):
TeamTypeTeam configuration -
triggerConfig (optional):
TriggerConfigType[]-
channel:
stringReference to Messaging Channel - defaults to Now Assist Panel. Use string value: "Now Assist Panel" -
name:
stringName of the trigger -
active:
booleanActive status - defaults to false -
businessRule:
string | Record<'sys_script'> | BusinessRule<unknown>Reference to Business Rule (sys_id, Record<'sys_script'>, or BusinessRule) -
description:
stringDescription of the trigger -
domain:
stringDomain ID -
enableDiscovery:
booleanEnable discovery flag - defaults to FALSE -
notificationScript:
string | Record<'sys_script_client'> | ClientScriptProps<unknown, client_script_events, boolean>Reference to Client Script for notifications -
objectiveTemplate:
stringObjective 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:
stringRun as field name -
runAsScript:
string | (current: any, dependencies: any[]) => stringRun 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:
ScheduleConfigWorkflowTypeSchedule configuration - used for scheduled triggers (scheduled, daily, weekly, monthly) -
showNotifications:
booleanShow 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:
unknownTarget table name (Table Name) -
triggerCondition:
stringConditions for the trigger -
triggerFlowDefinitionType:
TriggerFlowDefinitionTrigger flow definition type - choices: record_create, record_create_or_update, record_update, email, scheduled, daily, weekly, monthly
-
-
versions (optional):
AIAVersion[]-
name:
stringVersion name (Translated Text) -
condition:
stringCondition (Condition String) -
instructions:
stringInstructions (Translated Text) -
number:
numberVersion 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",
},
],
});