Logo Workflow Creation

Workflow Creation

Tổ chức
Happy-Technologies-LLC
workflow-creation

Programmatic workflow creation via API/MCP - build complete workflows without the UI editor

Tổng quan

Nhà phát hànhHappy-Technologies-LLC
Kho mãhappy-platform-skills
Tên kỹ năngworkflow-creation
Sao
41
Bản fork
14
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Đầy đủ trong hướng dẫn

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được Happy-Technologies-LLC công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Workflow Creation trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/Happy-Technologies-LLC/happy-platform-skills/tree/main/skills/admin/workflow-creation
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Happy-Technologies-LLC/happy-platform-skills.git /tmp/happy-platform-skills
mkdir -p .claude/skills
cp -r /tmp/happy-platform-skills/skills/admin/workflow-creation .claude/skills/workflow-creation
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Workflow Creation trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Workflow Creation ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Workflow Creation không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Programmatic Workflow Creation

Overview

This skill enables you to create complete ServiceNow workflows entirely via API/MCP without using the visual Workflow Editor. This is essential for:

  • Automation pipelines - Create workflows as part of CI/CD deployments
  • Templated solutions - Generate standardized workflows from templates
  • Mass creation - Build multiple similar workflows programmatically
  • Version control - Store workflow definitions as code in Git
  • Environment migration - Recreate workflows across instances

Key Discovery: Activities store their logic in the input field as JavaScript code. This enables full programmatic workflow creation by:

  1. Creating the workflow structure (wf_workflow, wf_workflow_version)
  2. Creating activities with embedded scripts (wf_activity)
  3. Linking activities with transitions (wf_transition, wf_condition)
  4. Publishing the workflow version

Prerequisites

  • Roles: admin or workflow_admin
  • Permissions: Write access to workflow tables (wf_*)
  • Knowledge: Basic understanding of workflow concepts
  • Environment: Development or test instance (never create workflows in production first)
  • Related Skills: admin/update-set-management - Capture workflows in update sets

Table Architecture

Understanding the workflow tables is critical for programmatic creation.

Core Tables

wf_workflow (base definition)
    |
    +-- wf_workflow_version (published versions)
            |
            +-- wf_activity (activities with scripts)
            |       |
            |       +-- wf_element_definition (activity types)
            |       +-- wf_stage (optional stages)
            |
            +-- wf_transition (connects activities)
            |       |
            |       +-- wf_condition (transition logic)
            |
            +-- wf_condition (workflow-level conditions)

Key Relationships

TablePurposeKey Fields
wf_workflowBase workflow definitionname, table, description
wf_workflow_versionVersioned workflowworkflow, table, start, published
wf_activityIndividual activitiesworkflow_version, input, x, y
wf_transitionActivity connectionsfrom, to, condition
wf_conditionTransition conditionsactivity, condition, else_flag
wf_element_definitionActivity type definitionsname, default_input

Procedure

Step 1: Discover Activity Types

First, identify available activity types (wf_element_definition).

Using MCP:

Tool: SN-Query-Table
Parameters:
  table_name: wf_element_definition
  query: active=true
  fields: sys_id,name,category,description
  limit: 50

Common Activity Types:

sys_idNameUse Case
0a6c97790a0a0b2756919eb960284334NotificationSend email/SMS
1ca8d7cf0a0a0b265e9a000c2c08248cSet ValuesSet field values
35433da80a0a029a0028c639a1e51eb4Approval - UserUser approval
354e911f0a0a029a00e6a0e6ad74206fApproval - GroupGroup approval
283e8bb80a2581021d036a052ffc3433Approval CoordinatorMulti-approval container
38891b6f0a0a0b1e00efdfdd77602027Catalog TaskCreate catalog task
3961a1da0a0a0b5c00ecd84822f70d85TimerWait/delay
396807940a0a0b5c00afd9f67d9fd7a2Log MessageDebug logging
5994b389c0a80011000e64de81b1864cSubflowCall another workflow
7c9a2ba9c0a801650021ada408de0ebdJoinWait for multiple paths
7a8ea386c0a80066179bc1f5186e1d2bRollbackGo back to earlier activity

Note: Custom script activities can omit activity_definition entirely.

Step 2: Create Base Workflow

Create the workflow container record.

Using MCP (Preferred):

Tool: SN-Create-Workflow
Parameters:
  name: "P1 Incident Auto-Assignment"
  table: "incident"
  description: "Auto-assign P1 incidents to on-call engineer"
  condition: "priority=1^state=1"

Using SN-Create-Record:

Tool: SN-Create-Record
Parameters:
  table_name: wf_workflow
  data:
    name: "P1 Incident Auto-Assignment"
    description: "Auto-assign P1 incidents to on-call engineer"
    template: false
    access: "public"

Important: The name and table fields become read-only after creation. Choose carefully.

Save the sys_id: workflow_sys_id

Step 3: Create Workflow Version

Create a version that holds the actual workflow logic.

Using MCP:

Tool: SN-Create-Record
Parameters:
  table_name: wf_workflow_version
  data:
    name: "P1 Incident Auto-Assignment"
    workflow: [workflow_sys_id]
    table: "incident"
    condition: "priority=1^state=1"
    active: true
    published: false
    order: 100
    run_multiple: false
    after_business_rules: true

Key Fields:

FieldPurposeNotes
tableTarget tableREQUIRED - what records trigger this
conditionTrigger conditionEncoded query format
activeIs activeSet true for workflow to run
publishedIs publishedSet false initially, publish after testing
run_multipleAllow concurrent instancesUsually false
after_business_rulesWhen to runUsually true

Save the sys_id: version_sys_id

Step 4: Create Activities

Create each activity with its embedded script.

Activity 1: Start Activity

Using MCP (Preferred):

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Check On-Call Engineer"
  x: 100
  y: 100
  script: |
    // Find on-call engineer
    var oncall = new GlideRecord('on_call_rotation');
    oncall.addQuery('active', true);
    oncall.addQuery('group', current.assignment_group);
    oncall.query();
    if (oncall.next()) {
      workflow.scratchpad.oncall_engineer = oncall.user.toString();
      gs.info('Found on-call: ' + oncall.user.name);
    } else {
      workflow.scratchpad.oncall_engineer = '';
      gs.warn('No on-call engineer found');
    }

Using SN-Create-Record:

Tool: SN-Create-Record
Parameters:
  table_name: wf_activity
  data:
    name: "Check On-Call Engineer"
    workflow_version: [version_sys_id]
    x: 100
    y: 100
    width: 150
    height: 80
    input: |
      // Script content here...

Save the sys_id: activity_start_id

Activity 2: Decision/Branch Activity

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Assign to On-Call"
  x: 250
  y: 100
  script: |
    // Assign incident based on on-call lookup
    if (workflow.scratchpad.oncall_engineer) {
      current.assigned_to = workflow.scratchpad.oncall_engineer;
      current.state = 2;  // In Progress
      current.work_notes = 'Auto-assigned to on-call engineer by workflow';
      current.update();
      answer = 'assigned';
      gs.info('Assigned to: ' + current.assigned_to.name);
    } else {
      answer = 'no_oncall';
      gs.warn('Could not assign - no on-call engineer');
    }

Save the sys_id: activity_assign_id

Activity 3: Notification Activity

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Send Notification"
  x: 400
  y: 100
  type: "notification"
  script: |
    // Send email notification
    var email = new GlideEmailOutbound();
    email.setSubject('P1 Incident Assigned: ' + current.number);
    email.setFrom('noreply@company.com');
    email.addAddress(current.assigned_to.email);
    email.setBody('You have been assigned P1 incident: ' + current.number + '\n' +
                  'Priority: 1\n' +
                  'Short Description: ' + current.short_description);
    email.send();
    gs.info('Notification sent to: ' + current.assigned_to.email);

Save the sys_id: activity_notify_id

Activity 4: Escalation Activity (Branch Path)

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Escalate to Manager"
  x: 250
  y: 250
  script: |
    // Escalate to manager
    var manager = current.assignment_group.manager;
    if (manager) {
      current.assigned_to = manager;
      current.escalation = 1;
      current.work_notes = 'Escalated to manager - no on-call engineer available';
      current.update();
      gs.info('Escalated to manager: ' + manager.name);
    }

Save the sys_id: activity_escalate_id

Step 5: Create Transition Conditions

Define conditions for branching paths.

Condition 1: "Assigned" Path

Tool: SN-Create-Record
Parameters:
  table_name: wf_condition
  data:
    activity: [activity_assign_id]
    name: "Assigned Successfully"
    short_description: "On-call engineer found and assigned"
    condition: "answer=assigned"
    order: 1

Save the sys_id: condition_assigned_id

Condition 2: "No On-Call" Path

Tool: SN-Create-Record
Parameters:
  table_name: wf_condition
  data:
    activity: [activity_assign_id]
    name: "No On-Call"
    short_description: "No on-call engineer found"
    condition: "answer=no_oncall"
    order: 2

Save the sys_id: condition_no_oncall_id

Else Condition (Default Path):

Tool: SN-Create-Record
Parameters:
  table_name: wf_condition
  data:
    activity: [activity_assign_id]
    name: "Default"
    short_description: "Default path"
    else_flag: true
    order: 99

Step 6: Create Transitions

Link activities together with transitions.

Using MCP (Preferred):

Tool: SN-Create-Transition
Parameters:
  from_activity_id: [activity_start_id]
  to_activity_id: [activity_assign_id]

Transition 1: Start to Assign

Tool: SN-Create-Record
Parameters:
  table_name: wf_transition
  data:
    from: [activity_start_id]
    to: [activity_assign_id]
    order: 1

Transition 2: Assign to Notify (Conditional)

Tool: SN-Create-Record
Parameters:
  table_name: wf_transition
  data:
    from: [activity_assign_id]
    to: [activity_notify_id]
    condition: [condition_assigned_id]
    order: 1

Transition 3: Assign to Escalate (Conditional)

Tool: SN-Create-Record
Parameters:
  table_name: wf_transition
  data:
    from: [activity_assign_id]
    to: [activity_escalate_id]
    condition: [condition_no_oncall_id]
    order: 2

Transition 4: Escalate to Notify (After Escalation)

Tool: SN-Create-Record
Parameters:
  table_name: wf_transition
  data:
    from: [activity_escalate_id]
    to: [activity_notify_id]
    order: 1

Step 7: Set Start Activity and Publish

Update the workflow version with the start activity and publish.

Using MCP (Preferred):

Tool: SN-Publish-Workflow
Parameters:
  workflow_version_id: [version_sys_id]
  start_activity_id: [activity_start_id]

Using SN-Update-Record:

Tool: SN-Update-Record
Parameters:
  table_name: wf_workflow_version
  sys_id: [version_sys_id]
  data:
    start: [activity_start_id]
    published: true

Step 8: Verify the Workflow

Query to verify workflow structure.

Check Activities:

Tool: SN-Query-Table
Parameters:
  table_name: wf_activity
  query: workflow_version=[version_sys_id]
  fields: sys_id,name,x,y

Check Transitions:

Tool: SN-Query-Table
Parameters:
  table_name: wf_transition
  query: from.workflow_version=[version_sys_id]
  fields: sys_id,from.name,to.name,condition.name

Check Workflow Version:

Tool: SN-Query-Table
Parameters:
  table_name: wf_workflow_version
  query: sys_id=[version_sys_id]
  fields: name,table,start.name,published,active

Workflow Context and Scripting

Available Variables in Activity Scripts

javascript
// The current record being processed
current

// Workflow scratchpad - share data between activities
workflow.scratchpad.your_variable = 'value';

// Activity result - determines which transition to follow
answer = 'approved';  // String that matches condition

// Current activity object
activity

// Workflow context
workflow.name
workflow.context.sys_id

Common Script Patterns

Pass Data Between Activities:

javascript
// Activity 1: Store data
workflow.scratchpad.user_tier = current.u_tier;
workflow.scratchpad.requires_approval = true;
workflow.scratchpad.approval_reasons = [];

// Activity 2: Use stored data
if (workflow.scratchpad.requires_approval) {
  var reasons = workflow.scratchpad.approval_reasons;
  // Process reasons...
}

Branch Logic with Answer Variable:

javascript
// Set answer to determine which transition fires
if (current.priority == 1) {
  answer = 'high_priority';
} else if (current.priority == 2) {
  answer = 'medium_priority';
} else {
  answer = 'low_priority';
}
// Create transitions with conditions: answer=high_priority, etc.

Error Handling:

javascript
try {
  var gr = new GlideRecord('incident');
  gr.get(current.sys_id);
  // Processing...
  answer = 'success';
} catch(e) {
  gs.error('Workflow error in ' + activity.name + ': ' + e.message);
  workflow.scratchpad.error_message = e.message;
  answer = 'error';
}

Logging for Debugging:

javascript
gs.info('[Workflow: ' + workflow.name + '] Activity: ' + activity.name);
gs.info('[Workflow] Processing incident: ' + current.number);
gs.info('[Workflow] Scratchpad data: ' + JSON.stringify(workflow.scratchpad));

Activity Type Examples

Approval - User

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Manager Approval"
  x: 300
  y: 150
  type: "35433da80a0a029a0028c639a1e51eb4"
  script: |
    // Create approval request for manager
    var approval = new GlideRecord('sysapproval_approver');
    approval.initialize();
    approval.document_id = current.sys_id;
    approval.source_table = current.getTableName();
    approval.approver = current.opened_by.manager;
    approval.state = 'requested';
    approval.insert();
    gs.info('Approval created for: ' + current.opened_by.manager.name);

Approval - Group

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "CAB Approval"
  x: 300
  y: 150
  type: "354e911f0a0a029a00e6a0e6ad74206f"
  script: |
    // Create group approval request
    var approval = new GlideRecord('sysapproval_group');
    approval.initialize();
    approval.document_id = current.sys_id;
    approval.source_table = current.getTableName();
    approval.assignment_group = 'CAB';  // sys_id or name
    approval.state = 'requested';
    approval.insert();

Catalog Task

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Create Fulfillment Task"
  x: 350
  y: 150
  type: "38891b6f0a0a0b1e00efdfdd77602027"
  script: |
    // Create catalog task
    var task = new GlideRecord('sc_task');
    task.initialize();
    task.request_item = current.sys_id;
    task.short_description = 'Fulfill: ' + current.short_description;
    task.assignment_group = current.assignment_group;
    task.state = 1;  // Open
    var taskId = task.insert();
    workflow.scratchpad.task_sys_id = taskId;
    gs.info('Created task: ' + task.number);

Timer/Wait

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Wait 24 Hours"
  x: 400
  y: 150
  type: "3961a1da0a0a0b5c00ecd84822f70d85"
  script: |
    // Timer configuration is typically in vars field
    // This activity waits before proceeding
    gs.info('Timer started - will continue in 24 hours');

Notification

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Send Email"
  x: 450
  y: 150
  type: "0a6c97790a0a0b2756919eb960284334"
  script: |
    // Send notification
    var email = new GlideEmailOutbound();
    email.setSubject('Request Update: ' + current.number);
    email.setFrom('noreply@company.com');
    email.addAddress(current.opened_by.email);
    email.setBody('Your request ' + current.number + ' has been processed.\n\n' +
                  'Status: ' + current.state.getDisplayValue());
    email.send();

Set Values

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Update Record Status"
  x: 500
  y: 150
  type: "1ca8d7cf0a0a0b265e9a000c2c08248c"
  script: |
    // Set field values
    current.state = 3;  // Closed
    current.close_code = 'Resolved';
    current.close_notes = 'Completed via workflow';
    current.closed_at = gs.nowDateTime();
    current.update();

Join (Wait for Multiple Paths)

Tool: SN-Create-Activity
Parameters:
  workflow_version_id: [version_sys_id]
  name: "Wait for All Approvals"
  x: 400
  y: 200
  type: "7c9a2ba9c0a801650021ada408de0ebd"
  script: |
    // Join waits for all incoming transitions to complete
    gs.info('All paths completed - continuing workflow');

Canvas Layout Best Practices

Coordinate System

Origin (0,0)
    +-----------------------------------------> X (horizontal)
    |
    |   [Start]       [Process]      [End]
    |   (100,100)     (250,100)      (400,100)
    |
    |                 [Branch A]
    |                 (250,200)
    |
    |                 [Branch B]
    |                 (250,300)
    |
    v
    Y (vertical)

Recommended Spacing

  • Start position: x=100, y=100
  • Horizontal spacing: 150-200 pixels between sequential activities
  • Vertical spacing: 100-150 pixels for branching paths
  • Standard dimensions: width=150, height=80

Layout Patterns

Linear Flow:

[Start] ---> [Process] ---> [End]
(100,100)    (250,100)      (400,100)

Decision Branch:

                +---> [Yes Path] --+
               /     (250,100)      \
[Decision] ---+                      +---> [Join]
(100,150)      \                    /     (400,150)
                +---> [No Path] ---+
                     (250,200)

Parallel Paths:

           +---> [Task 1] ---+
          /     (200,100)     \
[Start] -+                     +---> [Join] ---> [End]
(100,150) \                   /     (400,150)    (550,150)
           +---> [Task 2] ---+
                (200,200)

Testing Workflows

Pre-Publication Testing

  1. Verify Structure:
Tool: SN-Query-Table
Parameters:
  table_name: wf_activity
  query: workflow_version=[version_sys_id]
  fields: name,x,y
  1. Verify Transitions:
Tool: SN-Query-Table
Parameters:
  table_name: wf_transition
  query: from.workflow_version=[version_sys_id]
  fields: from.name,to.name,condition.name
  1. Test with Unpublished Version: Keep published: false during testing. The workflow will still run for manual testing.

Runtime Debugging

Enable Workflow Logging:

javascript
// Add to activities for debugging
gs.info('[WF-DEBUG] Activity: ' + activity.name);
gs.info('[WF-DEBUG] Current: ' + current.number);
gs.info('[WF-DEBUG] Scratchpad: ' + JSON.stringify(workflow.scratchpad));

View Workflow Context:

Tool: SN-Query-Table
Parameters:
  table_name: wf_context
  query: workflow_version=[version_sys_id]^state=executing
  fields: sys_id,state,started,scratchpad

View Activity History:

Tool: SN-Query-Table
Parameters:
  table_name: wf_history
  query: context.workflow_version=[version_sys_id]
  fields: activity.name,state,started,ended,output
  orderBy: started

Common Debug Queries

Find Failed Contexts:

Tool: SN-Query-Table
Parameters:
  table_name: wf_context
  query: workflow_version=[version_sys_id]^state=cancelled
  fields: sys_id,state,result,scratchpad

Find Stuck Activities:

Tool: SN-Query-Table
Parameters:
  table_name: wf_executing
  query: context.workflow_version=[version_sys_id]
  fields: activity.name,state,started

Versioning and Publishing

Version Workflow

Create New Version:

Tool: SN-Create-Record
Parameters:
  table_name: wf_workflow_version
  data:
    name: "P1 Incident Auto-Assignment v2"
    workflow: [workflow_sys_id]
    table: "incident"
    condition: "priority=1^state=1"
    active: true
    published: false

Then recreate activities and transitions for the new version.

Deactivate Old Version

Tool: SN-Update-Record
Parameters:
  table_name: wf_workflow_version
  sys_id: [old_version_sys_id]
  data:
    active: false

Publish New Version

Tool: SN-Update-Record
Parameters:
  table_name: wf_workflow_version
  sys_id: [new_version_sys_id]
  data:
    published: true

Tool Usage Summary

MCP Tools (Preferred)

ToolPurpose
SN-Create-WorkflowCreate workflow with activities in one call
SN-Create-ActivityAdd individual activity
SN-Create-TransitionLink activities together
SN-Publish-WorkflowSet start activity and publish
SN-Create-RecordGeneric record creation
SN-Update-RecordUpdate existing records
SN-Query-TableQuery workflow tables

REST API (Alternative)

EndpointMethodPurpose
/api/now/table/wf_workflowPOSTCreate workflow
/api/now/table/wf_workflow_versionPOSTCreate version
/api/now/table/wf_activityPOSTCreate activity
/api/now/table/wf_transitionPOSTCreate transition
/api/now/table/wf_conditionPOSTCreate condition
/api/now/table/wf_workflow_version/{id}PATCHUpdate/publish

Best Practices

  • Naming Convention: Use [Process] - [Trigger] format (e.g., "Approval - High Priority Change")
  • Activity Names: Use Verb + Noun format (e.g., "Check Approval Status", "Send Notification")
  • Start Simple: Create with 2-3 activities first, then add complexity
  • Test Early: Test with published: false before publishing
  • Add Logging: Include gs.info() statements for debugging
  • Error Handling: Wrap scripts in try-catch blocks
  • Use Scratchpad: Pass data via workflow.scratchpad, not global variables
  • Document Conditions: Use descriptive names for transition conditions
  • Version Control: Store workflow definitions as JSON/code in Git
  • Capture in Update Set: Always create workflows with an active update set

Troubleshooting

Workflow Not Triggering

Symptom: Workflow created but not executing Cause: Missing or incorrect trigger condition, or workflow not active/published Solution:

  1. Verify active: true on workflow version
  2. Verify published: true on workflow version
  3. Check trigger condition matches record criteria
  4. Verify after_business_rules setting
  5. Check workflow is assigned to correct table

Activity Not Executing

Symptom: Workflow starts but specific activity skipped Cause: Missing transition or incorrect condition Solution:

  1. Query transitions: from=[activity_sys_id]
  2. Verify condition matches answer value from previous activity
  3. Check activity has valid script in input field

Workflow Stuck

Symptom: Workflow context remains in "executing" state Cause: Activity script error or infinite loop Solution:

  1. Check System Logs for script errors
  2. Query wf_history for activity execution details
  3. Review activity scripts for errors
  4. Cancel stuck context if needed:
Tool: SN-Update-Record
Parameters:
  table_name: wf_context
  sys_id: [context_sys_id]
  data:
    state: cancelled

Transition Condition Not Matching

Symptom: Workflow takes wrong path Cause: Condition syntax or answer value mismatch Solution:

  1. Verify condition format: answer=value (no quotes)
  2. Check answer variable is set correctly in activity script
  3. Check condition order (lower order = higher priority)
  4. Use else_flag: true for default/fallback path

Script Errors in Activities

Symptom: Activity fails with script error Cause: Invalid JavaScript or API usage Solution:

  1. Test script in background script first
  2. Check variable scope (current, workflow available)
  3. Verify GlideRecord queries return results
  4. Add error handling:
javascript
try {
  // Script logic
} catch(e) {
  gs.error('Activity error: ' + e.message);
  answer = 'error';
}

Examples

Example 1: Simple Approval Workflow

Tool: SN-Create-Workflow
Parameters:
  name: "Simple Approval"
  table: "change_request"
  description: "Basic change approval workflow"
  condition: "type=normal"
  activities:
    - name: "Request Approval"
      x: 100
      y: 100
      script: |
        var approval = new GlideRecord('sysapproval_approver');
        approval.initialize();
        approval.document_id = current.sys_id;
        approval.source_table = 'change_request';
        approval.approver = current.assignment_group.manager;
        approval.state = 'requested';
        approval.insert();
        workflow.scratchpad.approval_id = approval.sys_id;
    - name: "Check Approval Status"
      x: 250
      y: 100
      script: |
        var approval = new GlideRecord('sysapproval_approver');
        approval.get(workflow.scratchpad.approval_id);
        answer = approval.state.toString();
    - name: "Approved Actions"
      x: 400
      y: 50
      script: |
        current.state = 'authorize';
        current.work_notes = 'Change approved by workflow';
        current.update();
    - name: "Rejected Actions"
      x: 400
      y: 150
      script: |
        current.state = 'cancelled';
        current.work_notes = 'Change rejected by workflow';
        current.update();
  transitions:
    - from: 0
      to: 1
    - from: 1
      to: 2
      condition: "answer=approved"
    - from: 1
      to: 3
      condition: "answer=rejected"

Example 2: Multi-Level Approval

Creating a workflow with parallel approvals that join before completion.

Step 1: Create Base Structure

Tool: SN-Create-Record
Parameters:
  table_name: wf_workflow
  data:
    name: "Multi-Level Approval"
    description: "Requires both manager and director approval"

Step 2: Create Activities (Create 6 activities: Start, Manager Approval, Director Approval, Join, Approved, Rejected)

Step 3: Create Parallel Transitions

// Start -> Manager Approval
// Start -> Director Approval (parallel path)
// Manager Approval -> Join
// Director Approval -> Join
// Join -> Approved (if all approved)
// Join -> Rejected (if any rejected)

Example 3: Incident Auto-Routing

javascript
// Complete workflow for routing incidents based on category

// 1. Create workflow
SN-Create-Record: wf_workflow
  name: "Incident Auto-Router"
  description: "Route incidents to appropriate team"

// 2. Create version
SN-Create-Record: wf_workflow_version
  table: "incident"
  condition: "active=true^assignment_groupISEMPTY"

// 3. Create routing activity
SN-Create-Activity:
  name: "Route by Category"
  script: |
    var category = current.category.toString();
    var routing = {
      'network': 'Network Support',
      'hardware': 'Hardware Support',
      'software': 'Software Support',
      'database': 'Database Team'
    };
    var group = routing[category] || 'Service Desk';
    var gr = new GlideRecord('sys_user_group');
    gr.addQuery('name', group);
    gr.query();
    if (gr.next()) {
      current.assignment_group = gr.sys_id;
      current.work_notes = 'Auto-routed to ' + group;
      current.update();
      answer = 'routed';
    } else {
      answer = 'no_group';
    }

Related Skills

  • admin/update-set-management - Capture workflows in update sets
  • admin/application-scope - Workflows in scoped applications
  • itsm/change-management - Change request workflows
  • itsm/incident-lifecycle - Incident handling workflows

References

Câu hỏi thường gặp

Kỹ năng AI Workflow Creation làm được gì?

Programmatic workflow creation via API/MCP - build complete workflows without the UI editor

Vì sao nên dùng Workflow Creation trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Workflow Creation là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Workflow Creation trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/Happy-Technologies-LLC/happy-platform-skills/tree/main/skills/admin/workflow-creation. TypingMind đọc tệp SKILL.md và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Workflow Creation?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Workflow Creation với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Workflow Creation với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Workflow Creation có miễn phí không?

Có. Kỹ năng này được Happy-Technologies-LLC phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇