Skip to main content
Version: 4.9.0

AiAgenticWorkflow

Configure an AI Agentic Workflow record. AI Agentic Workflows orchestrate multiple AI Agents working together as a team, with shared context, triggers, and version management in ServiceNow's AI Agent Studio.

Branding note: "Now Assist" has been rebranded to "ServiceNow Otto." These names refer to the same product. All technical identifiers (table names, field names, string literals like "Now Assist Panel", now_assist_deployment) remain unchanged — use them exactly as-is in code.

Signature

AiAgenticWorkflow(config)

Usage

import '@servicenow/sdk/global'
import { AiAgenticWorkflow } from '@servicenow/sdk/core'

AiAgenticWorkflow({
$id: Now.ID['my_workflow'],
name: 'My Workflow',
description: 'Orchestrates agents to analyze records',
recordType: 'custom',
securityAcl: {
$id: Now.ID['my_workflow_acl'],
type: 'Any authenticated user',
},
team: {
$id: Now.ID['my_team'],
name: 'My Team',
members: ['agent_sys_id_1', 'agent_sys_id_2'],
},
versions: [
{
name: 'V1',
number: 1,
state: 'published',
instructions: 'Analyze records and generate summaries.',
},
],
})

Parameters

config

AiAgenticWorkflowType

AI Agentic Workflow configuration object.

See the building-ai-agents-guide topic for team configuration, instructions authoring, trigger setup, and best practices.

Properties:

  • $id (required): string | number | ExplicitKey<string> Unique identifier for the workflow

  • protectionPolicy (optional): 'read' | 'protected' Controls edit/view access for other developers after the application is installed. 'read' lets others see the configuration but not change it. 'protected' prevents others from changing the record. Omit to allow customization.

  • $override (optional): Record<string, string | boolean | number> Set properties not directly supported by this API. Key-value pairs are written as additional fields on the generated record.

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

  • description (required): string Brief description of what the workflow does. Also auto-populates team.description.

  • securityAcl (required): SecurityAclUserAccessConfig Controls who can invoke the workflow. Automatically generates sys_security_acl and sys_security_acl_role records. Uses discriminated union on type: 'Any authenticated user', 'Specific role', or 'Public'. Requires $id and for 'Specific role', also requires roles array of role sys_ids.

  • active (optional): boolean Whether the workflow is active. Default: true

  • contextProcessingScript (optional): function | string Script to process context before workflow execution. Supports inline scripts or Now.include().

  • dataAccess (optional): DataAccessConfigWorkflowType Data access controls — required when runAs is not set. Defines which roles the workflow can inherit from the invoking user. Use roleMap (role names) or roleList (role sys_ids). At least one must be non-empty when runAs is not set.

  • executionMode (optional): 'copilot' | 'autopilot' Execution mode for the workflow. Default: 'copilot'

  • memoryScope (optional): string Memory scope for team members. Default: 'global'

  • recordType (optional): 'custom' | 'template' | 'aia_internal' Record type. Default: 'template'. Must set 'custom' for user-created workflows.

  • runAs (optional): string Field name for run-as user (dynamic resolution). When set, dataAccess is optional. When omitted, the workflow uses dynamic user identity and dataAccess becomes mandatory.

  • sysDomain (optional): string Domain ID. Default: 'global'

  • team (optional): TeamType Team configuration with nested members array. Key fields:

    • $id (required) — unique identifier for the team
    • name — team name
    • sysDomain — domain ID (default: 'global')
    • members — array of agent sys_ids or Record<'sn_aia_agent'> references

    Team description is auto-populated from the workflow's description. Do not set it manually.

  • triggerConfig (optional): TriggerConfigType[] Array of trigger configurations for automatic invocation. Supported types: 'record_create', 'record_create_or_update', 'record_update', 'email', 'scheduled', 'daily', 'weekly', 'monthly', 'ui_action'. Key fields: name, channel (use 'Now Assist Panel'), objectiveTemplate, targetTable, triggerFlowDefinitionType, triggerCondition. For scheduled triggers, use schedule nested object.

  • versions (optional): AIAVersion[] Array of version configurations. Key fields: name, number, state ('draft', 'committed', 'published', 'withdrawn'), instructions, condition.

Note: The following fields are auto-generated and should not be specified: internalName (auto-generated from domain.scope.name), trigger useCase (auto-populated with parent workflow ID).

Examples

Workflow with Data Access and Triggers

/**
* @title Workflow with Data Access and Triggers
* @description Create a workflow with role-based access and record/scheduled triggers
*/

import '@servicenow/sdk/global'
import { AiAgenticWorkflow } from '@servicenow/sdk/core'

export const exampleAgenticWorkflow = AiAgenticWorkflow({
$id: Now.ID['employee_record_summarization_workflow'],
name: 'Employee Record Summarization',
description: 'Analyzes employee records and generates summaries',
recordType: 'custom',

securityAcl: {
$id: Now.ID['employee_summarization_workflow_acl'],
type: 'Any authenticated user',
},

team: {
$id: Now.ID['employee_summarization_team'],
name: 'Employee Summarization Team',
members: [
'274b465a7d5f42e581664209557b2b18', // Record Summary Agent sys_id
'2dfb22af3351f2101ea99d273e5c7ba3', // Search Q&A Agent sys_id
],
},

versions: [
{
name: 'V1',
number: 1,
state: 'published',
instructions: 'Fetch employee record, analyze key fields, and generate summary',
},
{
name: 'V2',
number: 2,
instructions: 'Enhanced version with validation and department analysis',
},
],

triggerConfig: [
{
name: 'Employee Record Created',
targetTable: 'x_snc_cust_app_age_employee',
triggerFlowDefinitionType: 'record_create',
triggerCondition: 'first_nameISNOTEMPTY',
objectiveTemplate: 'Summarize employee record ${sys_id}',
runAsScript: Now.include('./run-as-script.js'),
showNotifications: true,
channel: 'Now Assist Panel',
},
{
name: 'Weekly Employee Review',
active: true,
targetTable: 'x_snc_cust_app_age_employee',
triggerCondition: 'first_nameISNOTEMPTY',
triggerFlowDefinitionType: 'scheduled',
objectiveTemplate: 'Review all employee records for the week',
schedule: {
runDayOfWeek: 2, // Monday
runDayOfMonth: 2,
starting: '1970-01-01 09:00:00',
time: '1970-01-01 09:00:00',
},
channel: 'Now Assist Panel',
},
],

dataAccess: {
roleMap: ['admin'],
description: 'Restrict workflow access to admin role',
},
})

Workflow with Fixed User Identity

/**
* @title Workflow with Fixed User Identity
* @description Create a workflow that runs as a specific user
*/

import '@servicenow/sdk/global'
import { AiAgenticWorkflow } from '@servicenow/sdk/core'

export const dynamicUserWorkflow = AiAgenticWorkflow({
$id: Now.ID['incident_management_workflow'],
name: 'Incident Management Workflow',
description: 'Analyzes incident records, identifies patterns, and provides resolution recommendations',
recordType: 'custom',
runAs: '<sys_user_id>',

securityAcl: {
$id: Now.ID['incident_management_workflow_acl'],
type: 'Any authenticated user',
},

team: {
$id: Now.ID['incident_workflow_team'],
name: 'Incident Management Team',
members: [],
},

versions: [
{
name: 'V1',
number: 1,
state: 'published',
instructions: 'Analyze incident ${number} with priority ${priority}. Identify potential root causes and suggest resolution steps.',
},
],
})

Workflow with Record References

/**
* @title Workflow with Record References
* @description Create a workflow using Record API for agent references
*/

import '@servicenow/sdk/global'
import { AiAgenticWorkflow, Record } from '@servicenow/sdk/core'

const summaryAgent = Record({
table: 'sn_aia_agent',
$id: Now.ID['summary_agent'],
data: { name: 'Record Summary Agent' },
})

const searchAgent = Record({
table: 'sn_aia_agent',
$id: Now.ID['search_agent'],
data: { name: 'Search Q&A Agent' },
})

export const analysisWorkflow = AiAgenticWorkflow({
$id: Now.ID['analysis_workflow'],
name: 'Analysis Workflow',
description: 'Workflow using Record references for agent members',
recordType: 'custom',

securityAcl: {
$id: Now.ID['analysis_workflow_acl'],
type: 'Any authenticated user',
},

dataAccess: {
roleMap: ['itil', 'user_admin'],
description: 'Data access for itil and user_admin roles',
},

team: {
$id: Now.ID['analysis_team'],
name: 'Analysis Team',
members: [summaryAgent, searchAgent],
},
})

For guidance on team configuration, agent decomposition, trigger setup, instructions authoring, and common patterns, see the building-ai-agents-guide topic.

Supported Record Types

Record TypeTableDescription
AI Agentic Workflowsn_aia_usecasePrimary workflow definition
AI Teamsn_aia_teamTeam configuration for the workflow
AI Team Membersn_aia_team_memberTeam member associations (agents in the team)
AI Versionsn_aia_versionVersion information for the workflow
Use Case Config Overridesn_aia_usecase_config_overrideConfiguration overrides for the workflow
Trigger Configurationsn_aia_trigger_configurationAutomated trigger definitions
Trigger Agent Usecase M2Msn_aia_trigger_agent_usecase_m2mMapping between triggers, workflows, and use cases
Agent Access Role Configurationsys_agent_access_role_configurationRole-based data access controls

Coalesce Keys

Coalesce keys determine how the plugin identifies existing records for updates (upsert behavior).

TableCoalesce Keys
sn_aia_usecasename
sn_aia_teamname
sn_aia_team_memberagent, team
sn_aia_versiontarget_id, version_name
sn_aia_trigger_configurationname, usecase
sn_aia_trigger_agent_usecase_m2mtrigger_configuration, related_resource_record
sn_aia_usecase_config_overrideusecase_configuration
sys_agent_access_role_configurationagent
sys_agent_access_role_mappingagent_access_config, role
sys_security_acl_rolesys_security_acl, sys_user_role

Field Mapping (Fluent → ServiceNow)

Workflow (sn_aia_usecase)

Fluent PropertyServiceNow FieldNotes
namename
descriptiondescriptionAlso auto-populates team.description
recordTyperecord_typeDefault: 'template' — set 'custom' for user-created
executionModeexecution_modeDefault: 'copilot'
activeactiveDefault: true
sysDomainsys_domainDefault: 'global'
contextProcessingScriptcontext_processing_scriptAuto CDATA wrapped

Team (sn_aia_team)

Fluent PropertyServiceNow FieldNotes
team.$idrecord IDMandatory for teams
team.namenameAuto-generated from workflow name if omitted
team.sysDomainsys_domainDefault: 'global'
team.descriptiondescriptionAuto-populated from workflow description — do not set manually

Team Members (sn_aia_team_member)

Fluent PropertyServiceNow FieldNotes
team.members[n]agentAgent sys_id or Record<'sn_aia_agent'>
memoryScopememory_scopeDefault: 'global'

Use Case Config (sn_aia_usecase_config_override)

Fluent PropertyServiceNow FieldNotes
runAsrun_as_userReference to sys_user
activeactive

Version (sn_aia_version)

Fluent PropertyServiceNow FieldNotes
versions[n].nameversion_name
versions[n].numberversion_numberDefault: 1
versions[n].statestateDefault: 'draft'
versions[n].instructionsinstructions
versions[n].conditioncondition

Trigger Config (sn_aia_trigger_configuration)

Fluent PropertyServiceNow FieldNotes
namename
descriptiondescription
activeactiveDefault: false
channelchannelUse 'Now Assist Panel' — auto-resolved to sys_id
triggerConditionconditionEncoded query
objectiveTemplateobjective_template
targetTabletarget_table
triggerFlowDefinitionTypetrigger_flow_definition_type
runAsrun_as
runAsScriptrun_as_scriptAuto CDATA wrapped
runAsUserrun_as_user
enableDiscoveryenable_discoveryDefault: false
showNotificationsshow_notificationsDefault: false
domainsys_domainDefault: 'global'
useCaseusecaseAuto-set to parent workflow ID
schedule.runDayOfMonthrun_dayofmonthNumber (1-31)
schedule.runDayOfWeekrun_dayofweekNumber (1=Sunday, 7=Saturday)
schedule.repeatIntervalrun_periodDuration format
schedule.startingrun_startYYYY-MM-DD HH:MM:SS
schedule.timerun_time1970-01-01 HH:MM:SS
schedule.triggerStrategytrigger_strategy
notificationScriptnotification_scriptClient script for handling notifications
profileprofileServiceNow Otto deployment profile
portalportalServiceNow Otto deployment channel
businessRulebusiness_ruleReference to business rule
sysOverridessys_overridesOverride the trigger configuration record
m2mSysOverridessys_overrides (on M2M)Override the trigger-workflow-usecase mapping
triggerFlowtrigger_flowReference to Flow Designer flow