Clocked Invoice Processing Engine with Injection, Extract and Decide
n8n Clocked Custom Node
Source Code
Introduction
Workflow automation has evolved beyond connecting APIs and moving data between applications. Modern workflows increasingly need to understand documents, extract structured information, classify incidents, protect sensitive information, and verify whether an answer is supported by available evidence.
This is where AI-powered workflow automation becomes valuable.
n8n is a flexible workflow automation platform that allows developers to connect APIs, applications, databases, and services through visual workflows. However, integrating a specialized AI platform into n8n can require custom HTTP requests, authentication configuration, request formatting, and error handling.
Clocked by Rezolve.ai provides AI capabilities that can be integrated into automated workflows. Rather than implementing every integration separately, you can create a reusable custom n8n community node that exposes Clocked API operations directly inside the n8n editor.
In this article, you will be guided on how to build n8n-nodes-clocked, a custom n8n node designed to connect workflows with Clocked.
The implementation brings together multiple capabilities, including:
- Decide: Evaluate structured questions against a given context.
- Extract: Transform unstructured text into structured data.
- Fill: Combine extracted facts, decisions, scores, and explicitly requested generated text in one record.
- PII protection: Detect and anonymize personally identifiable information.
- Injection guarding: Inspect untrusted content for prompt-injection attempts.
- Script inspection: Evaluate scripts against specified policies.
- Grounding verification: Check answers against supplied evidence.
- Document comparison: Compare documents.
- Reranking: Support relevance-based ranking workflows.
- Pipelines: Access supported Clocked pipeline operations.
The objective is simple: make Clocked capabilities reusable building blocks in visual automation workflows.
Background
Why build a custom n8n node?
n8n supports HTTP requests, making it possible to integrate almost any API. So why build a custom node?
A custom node creates a more convenient and consistent integration experience.
Instead of configuring authentication, request headers, endpoint URLs, retry behavior, and response handling separately in every workflow, developers can centralize these responsibilities in a reusable package.
For example, consider a workflow that processes incoming IT support tickets.
Without a custom node, developers might need to configure individual HTTP Request nodes for classification, extraction, privacy protection, and other AI operations.
With a Clocked node, the workflow can use a dedicated node for each operation and pass data between them.
Architecture overview
The integration follows a straightforward architecture:
The custom node acts as an integration layer between n8n and the Clocked API. It handles the mechanics of making API requests while allowing workflow designers to control operation-specific inputs.
What does the custom node provide?
The n8n-nodes-clocked implementation includes several useful integration features:
| Feature | Purpose |
|---|---|
| Multiple operations | Exposes ten Clocked operation categories |
| API credentials | Stores the API key and base URL in n8n credentials |
| JSON request bodies | Preserves operation-specific request fields |
| Idempotency keys | Supports safer handling of retried requests where the API honors idempotency |
| Retry logic | Retries eligible transient failures using exponential backoff |
| Response metadata | Can expose HTTP and timing information |
| Binary-related workflows | Supports relevant PDF and image data handling through the request format |
| Custom node icon | Includes the Clocked SVG asset in the build output |
These features make the integration suitable for building reusable AI-powered workflows without duplicating API integration logic.
The node is designed to preserve the flexibility of the underlying API rather than restricting developers to a small collection of predefined prompts.
Demo Invoice Processing
Clocked Invoice Processing Engine with Injection, Extract and Decide
For a production-grade invoice processing engine, use the following logical sequence:
- Receive: Accept invoice text or the output of an upstream OCR/document-parsing service.
- Validate: Check that the request contains usable invoice content and a request identifier.
- Secure: Run Clocked Injection Guard before any downstream AI processing.
- Extract: Use Clocked Extract to produce structured invoice data.
- Validate: Check arithmetic and line-item consistency using deterministic application logic wherever possible.
- Decide: Use Clocked Decide to evaluate business rules and recommend the next action.
- Review: Route invoices with missing fields, failed checks, uncertain results, or material discrepancies to a human reviewer.
- Integrate: Send validated invoice data and the decision outcome to the ERP or finance system.
- Respond: Return a consistent JSON response and record the processing status, evidence, and errors.
HTTP Request
{ "raw_invoice_text": "RUMPKE\n\n3800 STRUBLE RD\nCINCINNATI OH 45251\n\nCustomer #: 1234987650\nAccess Code: 515151515\n\nDate: 08/04/20\nService Period: AUGUST\nPage 1 of 1\n\nFor Service & Billing Call\n(800) 828-8171\n\nService Address: 1234 CUSTOMER AVE CLEVELAND OH 44114\n\nJOHN DOE\n1234 CUSTOMER AVE\nCLEVELAND OH 44114\n\nInvoice #: 0998811\nInvoice Total: 329.74\nDue Date: 08/19/20\n\n<table><thead><tr><th>Date</th><th>Description</th><th>Qty</th><th>Price</th><th>Total</th></tr></thead><tbody><tr><td>08/01/20</td><td>2YD FL/MONTH-MSW</td><td>1.00</td><td>116.32</td><td>116.32</td></tr><tr><td>08/01/20</td><td>FL CASTER SVC</td><td>2.00</td><td>5.00</td><td>10.00</td></tr><tr><td>08/01/20</td><td>FUEL SURCHARGE FL</td><td>1.00</td><td>29.89</td><td>29.89</td></tr><tr><td>08/03/20</td><td>2YD FL/MONTH-MSW</td><td>1.00</td><td>116.32</td><td>116.32</td></tr><tr><td>08/03/20</td><td>FL CASTER SVC</td><td>1.00</td><td>5.00</td><td>5.00</td></tr><tr><td>08/03/20</td><td>FUEL SURCHARGE FL</td><td>1.00</td><td>28.74</td><td>28.74</td></tr><tr><td></td><td>TAXES:</td><td></td><td></td><td>23.47</td></tr><tr><td></td><td>TOTAL:</td><td></td><td></td><td>329.74</td></tr></tbody></table>\n\n<table><thead><tr><th>Current</th><th>Over 30 Days</th><th>Over 60 Days</th><th>Over 90 Days</th><th>Unapplied</th></tr></thead><tbody><tr><td>329,74</td><td>329,74</td><td>,00</td><td>,00</td><td>,00</td></tr></tbody></table>\n\nFOLD HERE AND THEN SEPARATE\nRETURN THIS PORTION WITH PAYMENT. DO NOT ATTACH CHECK TO STUB\n\n<table><thead><tr><th>Date:</th><th>CUSTOMER NUMBER</th><th>INVOICE</th><th>INVOICE AMOUNT</th><th>DUE DATE</th></tr></thead><tbody><tr><td>08/04/20</td><td>1234987650</td><td>0998811</td><td>329.74</td><td>08/19/20</td></tr></tbody></table>\n\nRUMPKE OF OHIO INC\nPO BOX 538710\nCINCINNATI OH 45253-8710\n\nJOHN DOE\n1234 CUSTOMER AVE\nCLEVELAND OH 44114\n\n8438320082027800204160090135" } HTTP Response
{ "success": true, "status": "processed", "engine": "clocked-invoice-processing", "request_id": "320", "security": { "verdict": "safe", "result": { "operation": "injection", "data": { "model": "clocked-1.0", "injection": 0.011038893324682553, "verdict": "benign", "threshold": 0.5, "source": "content", "instructions_used": "custom", "category": "benign", "categories": { "benign": 0.9949117428312081, "instruction override": 0.0011078429067427334, "role-play or persona jailbreak": 0.0006937637302626613, "system prompt or secret extraction": 0.0006687358090757294, "obfuscated or encoded payload": 0.0007610243935540886, "tool misuse or data exfiltration": 0.0008035748452657817, "social engineering": 0.0010533154838909156 }, "severity": "none", "severity_expected": 1.029, "severities": { "none": 0.9875242778773807, "low": 0.0027749316211072928, "medium": 0.004831330489048606, "high": 0.002780297362575183, "critical": 0.002089162649888188 }, "evidence": [], "timing": { "read_ms": 114, "total_ms": 114 } }, "metadata": { "status": 200, "idempotencyKey": "bbce4634-3048-4cd9-afab-52ae6569adca", "attempts": 1, "modelMs": 93.066978, "credits": 4, "costUsd": 0.000797, "costBasis": "reference", "serverTiming": { "admit": 54.2, "admit_db": 6.6, "upstream": 170.2, "discovery": 0, "model": 93.1, "settle": 5.5, "gateway": 229.8 }, "headers": { "access-control-allow-headers": "Authorization,Content-Type,Idempotency-Key", "access-control-allow-methods": "POST,OPTIONS", "access-control-allow-origin": "*", "access-control-expose-headers": "Server-Timing,X-Clocked-Transport,X-Clocked-Model-Ms,X-Clocked-Credits,X-Clocked-Cost-Usd,X-Clocked-Cost-Basis", "alt-svc": "h3=\":443\"; ma=86400", "cache-control": "no-store", "cf-cache-status": "DYNAMIC", "cf-ray": "a52f12443d88404f-BOM", "connection": "keep-alive", "content-length": "772", "content-security-policy": "default-src 'self'; script-src 'self' https://www.googletagmanager.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://*.google-analytics.com https://*.googletagmanager.com https://*.g.doubleclick.net https://*.google.com; font-src 'self'; connect-src 'self' https://*.modal.host https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://*.g.doubleclick.net https://*.google.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests", "content-type": "application/json", "date": "Sat, 31 Oct 2026 02:01:21 GMT", "nel": "{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}", "permissions-policy": "camera=(), microphone=(), geolocation=()", "referrer-policy": "strict-origin-when-cross-origin", "report-to": "{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=NGMaDgQ%2BaQV829z0l4A9A312YIt3EsysF8Pp1QRruxg1TUuv2e7AGnj1UurseMh%2FYPMLSBzvQcPQQ3ecaS7uOu2wRNmRBIH9R4nW%2Fo84PQkRCULodE4enRpjxFp%2B9sYAlq2TEa8%3D\"}]}", "server": "cloudflare", "server-timing": "admit;dur=54.2, admit_db;dur=6.6, upstream;dur=170.2, discovery;dur=0.0, model;dur=93.1, settle;dur=5.5, gateway;dur=229.8", "strict-transport-security": "max-age=31536000", "x-clocked-cost-basis": "reference", "x-clocked-cost-usd": "0.000797", "x-clocked-credits": "4", "x-clocked-model-ms": "93.066978", "x-clocked-transport": "door:east", "x-content-type-options": "nosniff", "x-frame-options": "DENY", "x-vercel-cache": "MISS", "x-vercel-id": "bom1::iad1::lkmgj-1793412081382-212528b8bb97" }, "requestId": null } } }, "result": { "extraction": { "operation": "extract", "data": { "model": "clocked-1.0", "fields": { "vendor_name": { "value": "RUMPKE", "start": 0, "end": 6, "confidence": 0.9999998394211231, "p_verify": 0.9999998394211231 }, "vendor_address": { "value": "3800 STRUBLE RD\nCINCINNATI OH 45251", "start": 8, "end": 43, "confidence": 0.9999999853458998, "p_verify": 0.9999999853458998 }, "account_number": { "value": "1234987650", "start": 57, "end": 67, "confidence": 0.9999999994989419, "p_verify": 0.9999999994989419 }, "invoice_number": { "value": "0998811", "start": 299, "end": 306, "confidence": 0.9999999994771678, "p_verify": 0.9999999994771678 }, "invoice_date": { "value": null, "confidence": 1 }, "due_date": { "value": null, "confidence": 1 }, "currency_code": { "value": null, "confidence": 1 }, "subtotal": { "value": null, "confidence": 1 }, "tax": { "value": "23.47", "start": 1059, "end": 1064, "confidence": 0.9999999995308722, "p_verify": 0.9999999995308722 }, "total": { "value": "329.74", "start": 322, "end": 328, "confidence": 0.9999999992613431, "p_verify": 0.9999999992613431 }, "bill_to_name": { "value": "JOHN DOE", "start": 241, "end": 249, "confidence": 0.9999999983752754, "p_verify": 0.9999999983752754 }, "bill_to_address": { "value": "1234 CUSTOMER AVE CLEVELAND OH 44114", "start": 203, "end": 239, "confidence": 0.9999999906373053, "p_verify": 0.9999999906373053 }, "service_period": { "value": "AUGUST", "start": 123, "end": 129, "confidence": 0.9999999990070305, "p_verify": 0.9999999990070305 }, "line_items": { "value": null, "confidence": 1 } }, "timing": { "read_ms": 739, "forwards": { "fields": [ 25, 1 ] }, "stages": { "fields": { "reader": "recognition", "doc": 47, "branches": 2, "generate": 648, "locate": 0, "verify": 39, "assemble": 0 } }, "total_ms": 739, "server_ms": 746 } }, "metadata": { "status": 200, "idempotencyKey": "d299e120-fdd1-40e5-83f8-8353730e4e52", "attempts": 1, "modelMs": 739.313904, "credits": 30, "costUsd": 0.005976, "costBasis": "reference", "serverTiming": { "admit": 5.3, "admit_db": 1.5, "upstream": 773.1, "discovery": 0, "model": 739.3, "settle": 4.5, "gateway": 782.9 }, "headers": { "access-control-allow-headers": "Authorization,Content-Type,Idempotency-Key", "access-control-allow-methods": "POST,OPTIONS", "access-control-allow-origin": "*", "access-control-expose-headers": "Server-Timing,X-Clocked-Transport,X-Clocked-Model-Ms,X-Clocked-Credits,X-Clocked-Cost-Usd,X-Clocked-Cost-Basis", "alt-svc": "h3=\":443\"; ma=86400", "cache-control": "no-store", "cf-cache-status": "DYNAMIC", "cf-ray": "a52f12480f98404f-BOM", "connection": "keep-alive", "content-security-policy": "default-src 'self'; script-src 'self' https://www.googletagmanager.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://*.google-analytics.com https://*.googletagmanager.com https://*.g.doubleclick.net https://*.google.com; font-src 'self'; connect-src 'self' https://*.modal.host https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanage...


