AutomationFlowsData & Sheets › Job.6_fsm_mutator

Job.6_fsm_mutator

job.6_fsm_mutator. Uses postgres. Event-driven trigger; 5 nodes.

Event trigger★★★★☆ complexity5 nodesPostgres
Data & Sheets Trigger: Event Nodes: 5 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "job.6_fsm_mutator",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "69b67ac7-81f5-402e-9ffe-9d31b306d748",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT current_state\nFROM job_applications\nWHERE application_id = {{$json.application_id}};",
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        432,
        208
      ],
      "id": "8bd17028-1e28-4a9a-bc2c-007b6d1266b4",
      "name": "Check state matches",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "66ba2f81-c438-4404-86af-b0a4ec046c2e",
              "leftValue": "={{ $json.current_state === $node[\"Select eligible transitions\"].json.from_state }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        640,
        208
      ],
      "id": "f470ce8a-eef6-4c94-828e-73638fa68aef",
      "name": "If"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT\n  ev.event_id      AS fsm_event_id,\n  ev.application_id,\n  ev.payload->>'from_state' AS from_state,\n  ev.payload->>'to_state'   AS to_state\nFROM events ev\nLEFT JOIN events done\n  ON done.event_type = 'STATE_TRANSITIONED'\n AND done.payload->>'fsm_event_id' = ev.event_id::text\nWHERE ev.event_type = 'FSM_TRANSITION_ELIGIBLE'\n  AND done.event_id IS NULL;\n",
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        208,
        208
      ],
      "id": "96967178-7e7b-4238-a459-ca0670203104",
      "name": "Select eligible transitions",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "BEGIN;\n\nUPDATE job_applications\nSET\n  current_state = '{{$node[\"Select eligible transitions\"].json.to_state}}',\n  last_state_change = NOW()\nWHERE application_id = {{$node[\"Select eligible transitions\"].json.application_id}}\n  AND current_state = '{{$node[\"Select eligible transitions\"].json.from_state}}';\n\nINSERT INTO events (\n  event_type,\n  application_id,\n  payload,\n  triggered_by\n) VALUES (\n  'STATE_TRANSITIONED',\n  {{$node[\"Select eligible transitions\"].json.application_id}},\n  jsonb_build_object(\n    'fsm_event_id', {{$node[\"Select eligible transitions\"].json.fsm_event_id}},\n    'from_state', '{{$node[\"Select eligible transitions\"].json.from_state}}',\n    'to_state', '{{$node[\"Select eligible transitions\"].json.to_state}}'\n  ),\n  'system'\n);\n\nCOMMIT;\n",
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        832,
        -16
      ],
      "id": "6053fead-593b-41da-bf57-82db0c4b5653",
      "name": "Apply mutation",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Select eligible transitions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check state matches": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select eligible transitions": {
      "main": [
        [
          {
            "node": "Check state matches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Apply mutation",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "7d7382cb-f09d-4168-a487-98beb658d246",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "XSGcd0B9a036EEbd",
  "tags": []
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

job.6_fsm_mutator. Uses postgres. Event-driven trigger; 5 nodes.

Source: https://github.com/daemon-Ad/Job-Aggregation-and-Email-Intelligence-System/blob/main/workflows/job.6_fsm_mutator.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

Reagendamiento_v2. Uses executeWorkflowTrigger, redis, httpRequest, n8n-nodes-evolution-api. Event-driven trigger; 89 nodes.

Execute Workflow Trigger, Redis, HTTP Request +3
Data & Sheets

This workflow acts as a junior finance research analyst for a UK boutique M&A or corporate finance team. It listens for Slack messages, classifies the request, gathers company or market data, and prod

HTTP Request, Google Drive, Google Docs +5
Data & Sheets

Agendamiento_v2. Uses n8n-nodes-evolution-api, redis, httpRequest, executeWorkflowTrigger. Event-driven trigger; 59 nodes.

N8N Nodes Evolution Api, Redis, HTTP Request +3
Data & Sheets

Cancelacion_v2. Uses executeWorkflowTrigger, redis, httpRequest, n8n-nodes-evolution-api. Event-driven trigger; 46 nodes.

Execute Workflow Trigger, Redis, HTTP Request +3
Data & Sheets

Components. Uses postgres, readWriteFile. Event-driven trigger; 42 nodes.

Postgres, Read Write File