Skip to main content

n8n Integration

Build automated AI agent payment workflows using the official AGIRAILS n8n community node - no code required.

What You'll Learn

By the end of this guide, you'll have:

  • Installed the ACTP node in your n8n instance
  • Created a requester workflow that pays for AI services
  • Created a provider workflow that delivers services and gets paid
  • Connected both workflows for end-to-end automation

Estimated time: 30 minutes to working workflow

Difficulty: Beginner (no coding required)

Current Version: v1.1.1


Prerequisites​

Before starting, ensure you have:

Security Warning

Never use mainnet private keys in n8n. Only use testnet wallets with no real funds. Private keys are stored in n8n's credential system.


Architecture Overview​

The ACTP n8n node enables visual workflow automation for AI agent payments:

n8n Architecture Overview

What You Can Build​

Use CaseDescription
AI Service MarketplacePay AI agents for completed work automatically
Multi-Agent PipelinesChain multiple AI services with escrow payments
Automated SettlementsRelease funds when delivery is verified
Dispute HandlingRaise disputes when work doesn't meet requirements

Step 1: Install the ACTP Node​

n8n Cloud​

  1. Go to Settings β†’ Community Nodes
  2. Click Install a community node
  3. Enter: n8n-nodes-actp
  4. Click Install

Self-Hosted n8n​

cd ~/.n8n
npm install n8n-nodes-actp

Restart n8n to load the new node:

# If using PM2
pm2 restart n8n

# If running directly
n8n start

Verify Installation​

After installation, you should see the ACTP node in the node palette under the "Action" category.

Finding the Node

Search for "ACTP" in the node palette or look under Action in an App β†’ ACTP.


Step 2: Configure Credentials​

  1. In n8n, go to Credentials β†’ Add Credential
  2. Search for ACTP API
  3. Configure:
FieldValueDescription
Credential NameACTP TestnetYour label for this credential
Networkbase-sepoliaTestnet network
Private Key0x...Your testnet wallet private key
RPC URL(leave empty)Uses default public RPC
  1. Click Save
Multiple Credentials

Create separate credentials for different wallets (e.g., "ACTP Requester" and "ACTP Provider") to simulate different agents.


Step 3: Your First Payment (Quick Start)​

Let's create a simple workflow that locks funds in escrow.

Create the Workflow​

Quick Start Workflow

Node 1: Manual Trigger

  • Drag in the Manual Trigger node

Node 2: ACTP - Create Transaction

  • Credential: Select your ACTP credential
  • Operation: Create Transaction
  • Provider Address: 0x742d35Cc6634C0532925a3b844Bc9e7595f12345 (any valid address)
  • Amount (USDC): 1
  • Deadline: {{ $now.plus(1, 'day').toUnixInteger() }}
  • Dispute Window: 172800 (2 days in seconds)

Node 3: ACTP - Link Escrow

  • Credential: Select your ACTP credential
  • Operation: Link Escrow
  • Transaction ID: {{ $json.transactionId }}

Run It​

  1. Click Execute Workflow
  2. Check the output - you should see:
    • Transaction ID (bytes32 hash)
    • Escrow ID
    • State: COMMITTED

Congratulations! You just locked funds in escrow for an AI agent payment.


Available Operations​

Requester Operations (Paying for Services)​

OperationDescriptionWhen to Use
Create TransactionStart a new payment requestBeginning of workflow
Link EscrowLock USDC funds in escrowAfter creating transaction
Get TransactionCheck current state and detailsMonitoring, verification
Release With VerificationPay provider after verified deliveryAfter DELIVERED state
Verify AttestationValidate delivery proofBefore releasing payment
Raise DisputeTransition to DISPUTED stateWithin dispute window
Cancel TransactionCancel before work deliveredTimeout, provider unresponsive
V1: Admin-Only Dispute Resolution

In V1, "Raise Dispute" transitions the transaction to DISPUTED state by calling transitionState(DISPUTED). Either requester or provider can raise a dispute within the dispute window. However, only the platform admin can resolve the dispute by calling transitionState(SETTLED) with a resolution proof specifying fund distribution. Decentralized arbitration is planned for V2.

Provider Operations (Delivering Services)​

OperationDescriptionWhen to Use
Get TransactionVerify transaction detailsBefore starting work
Transition StateUpdate to IN_PROGRESS or DELIVEREDDuring work lifecycle

Operation Reference​

Create Transaction​

Creates a new ACTP transaction.

ParameterTypeRequiredDescription
Provider AddressstringYesEthereum address of service provider
Amount (USDC)numberYesPayment amount (min $0.05)
DeadlinenumberYesUnix timestamp when offer expires
Dispute WindownumberYesSeconds for dispute period (default 172800)
Dispute Window Guidelines
Trust LevelRecommended WindowSeconds
High-trust agents1 hour3600
Standard (default)2 days172800
High-value transactions7-30 days604800-2592000

Minimum: 1 hour (3600s) | Maximum: 30 days (2592000s)

Output:

{
"transactionId": "0x1234567890abcdef...",
"requester": "0xYourAddress...",
"provider": "0x742d35...",
"amount": "1000000",
"state": "INITIATED"
}

Locks USDC in the escrow vault. Automatically:

  1. Approves USDC spending to escrow contract
  2. Transfers exact transaction amount
  3. Transitions state to COMMITTED
ParameterTypeRequiredDescription
Transaction IDstringYesFrom Create Transaction output
Fee Timing

The 1% platform fee is deducted when funds are released, not when linking escrow. So if you lock $100, the full $100 is held until settlement.

Transition State​

Updates transaction state (provider only for most transitions).

Target StateWho Can CallWhen
QUOTEDProviderAfter reviewing request (optional)
IN_PROGRESSProviderWhen starting work
DELIVEREDProviderWhen work is complete

Release With Verification​

Securely releases payment after verifying delivery proof.

V1: SDK-Side Verification Only

In V1, the "Release With Verification" operation performs attestation verification off-chain via the SDK. The smart contract does not validate the attestation UID - it simply transitions to SETTLED and releases funds. The SDK checks that the attestation exists on EAS and was created by the provider before calling transitionState(SETTLED).

ParameterTypeRequiredDescription
Transaction IDstringYesThe delivered transaction
Attestation UIDstringYesProof ID from provider (read from attestationUID field)
What's an Attestation UID?

An Attestation UID is a bytes32 identifier for an EAS (Ethereum Attestation Service) attestation. The provider optionally creates this attestation when delivering work, then anchors it to the transaction by calling anchorAttestation().

V1 Limitations:

  • Anchoring an attestation is optional - providers may deliver without one
  • The contract does not validate the UID against EAS
  • Verification is performed by the SDK off-chain only
  • If no attestation was anchored, use the fallback flow without verification

Complete Tutorial: AI Translation Service​

This section walks through building two connected workflows - a Requester paying for AI translation and a Provider delivering it.

Overview​

AI Translation Service Flow

Communication Protocol​

Both workflows communicate via HTTP webhooks with standardized payloads.

Requester β†’ Provider (NEW_JOB):

{
"type": "NEW_JOB",
"transactionId": "0x1234...",
"requester": "0xRequesterAddress...",
"amount": "10000000",
"serviceRequest": {
"task": "translate",
"input": "Hello, how are you?",
"targetLanguage": "es"
},
"callbackUrl": "https://requester.com/webhook/delivery"
}

Provider β†’ Requester (DELIVERY):

{
"type": "DELIVERY",
"transactionId": "0x1234...",
"attestationUID": "0x1234...",
"result": {
"output": "Hola, ΒΏcΓ³mo estΓ‘s?",
"contentHash": "0xabcd...",
"completedAt": "2024-01-15T10:30:00Z"
}
}

Part 1: Requester Workflow​

This workflow pays for AI translation services.

Requester Workflow

Node Configuration​

Node 1: Webhook Trigger

SettingValue
Path/translation-request
MethodPOST
Response ModeWhen Last Node Finishes

Node 2: ACTP - Create Transaction

SettingValue
OperationCreate Transaction
Provider Address{{ $json.body.providerAddress }}
Amount (USDC)10
Deadline{{ $now.plus(1, 'day').toUnixInteger() }}
Dispute Window172800

Node 3: ACTP - Link Escrow

SettingValue
OperationLink Escrow
Transaction ID{{ $('Create Transaction').item.json.transactionId }}

Node 4: HTTP Request - Notify Provider

SettingValue
MethodPOST
URL{{ $json.body.providerWebhookUrl }}
BodyJSON with NEW_JOB payload

Node 5: Webhook - Wait for Delivery

SettingValue
Path/delivery-callback
MethodPOST

Node 6: ACTP - Release With Verification

SettingValue
OperationRelease With Verification
Transaction ID{{ $('Webhook Wait').item.json.body.transactionId }}
Attestation UID{{ $('Webhook Wait').item.json.body.attestationUID }}

Test the Requester​

curl -X POST https://your-n8n.com/webhook/translation-request \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, how are you?",
"targetLanguage": "es",
"providerAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f12345",
"providerWebhookUrl": "https://provider-n8n.com/webhook/new-job"
}'

Part 2: Provider Workflow​

This workflow delivers AI translation and gets paid.

Provider Workflow

Node Configuration​

Node 1: Webhook - New Job

SettingValue
Path/new-job
MethodPOST

Node 2: ACTP - Get Transaction

SettingValue
OperationGet Transaction
Transaction ID{{ $json.body.transactionId }}
Always Verify On-Chain

Even though the requester sent transaction details, always verify on-chain to prevent fake notifications.

Node 3: IF - Verify

ConditionValue
State equalsCOMMITTED
Provider matchesYour address

Node 4: ACTP - Transition State (IN_PROGRESS)

SettingValue
OperationTransition State
Transaction ID{{ $('Webhook').item.json.body.transactionId }}
Target StateIN_PROGRESS

Node 5: OpenAI - Translate

SettingValue
Modelgpt-4
PromptTranslate to {{ $json.body.serviceRequest.targetLanguage }}: {{ $json.body.serviceRequest.input }}

Node 6: ACTP - Transition State (DELIVERED)

SettingValue
OperationTransition State
Transaction ID{{ $json.transactionId }}
Target StateDELIVERED

Node 7: HTTP - Notify Requester

SettingValue
MethodPOST
URL{{ $('Webhook').item.json.body.callbackUrl }}
BodyDELIVERY payload with result

Connecting Both Workflows​

Step 1: Set Up Public Webhooks​

For local testing, use ngrok:

# Requester n8n (port 5678)
ngrok http 5678

# Provider n8n (port 5679)
ngrok http 5679

Step 2: Update URLs​

Update the HTTP request nodes with your ngrok URLs.

Step 3: Run End-to-End​

  1. Activate both workflows
  2. Trigger the requester workflow
  3. Watch both execution logs

What happens:

  1. Requester locks 10 USDC in escrow
  2. Provider receives job notification
  3. Provider verifies transaction on-chain
  4. Provider calls OpenAI to translate
  5. Provider marks as DELIVERED
  6. Requester releases payment
  7. Provider receives 9.9 USDC (after 1% fee)

Advanced Patterns​

Pattern 1: Multi-Agent Pipeline​

Chain multiple AI services with sequential payments:

Multi-Agent Pipeline

Pattern 2: Polling for Delivery​

If you can't receive webhooks, poll for state changes:

Polling Pattern

Pattern 3: Timeout Handling​

Cancel transactions that exceed deadline:

Timeout Pattern

Pattern 4: Service Discovery​

Look up providers from a registry:

Service Discovery Pattern

Production Checklist​

Before deploying to production:

Security​

  • Private keys stored only in n8n credentials (never in workflow data)
  • Webhook endpoints use HTTPS
  • Input validation on all webhook payloads
  • Rate limiting on webhook endpoints
  • IP whitelist for known callers

Reliability​

  • Error branches on all ACTP nodes
  • Retry logic for HTTP requests (3 retries, 10s interval)
  • Timeout handling with Cancel Transaction fallback
  • Logging to external database for audit trail
  • Health check workflow that monitors balances

Monitoring​

  • Alerts on failed transactions
  • Dashboard for transaction volume
  • Gas cost tracking
  • Balance monitoring with low-balance alerts

Economics​

  • Track fees paid (1% per transaction)
  • Monitor gas costs per operation
  • Set minimum profitable transaction size
  • Reserve balance for gas

Troubleshooting​

Common Issues​

IssueCauseSolution
"Invalid private key"Format errorMust start with 0x, exactly 66 chars
"Insufficient funds"Low balanceGet ETH from faucet, mint test USDC
"Invalid state transition"Wrong current stateCheck state with Get Transaction first
"Deadline passed"Transaction expiredCreate new transaction
"Only requester/provider"Wrong walletUse correct credential
Node not appearingInstallation issueRestart n8n, check logs

Debug Mode​

Add a Code node to log transaction state:

console.log('Transaction:', $json);
console.log('State:', $json.state);
console.log('Amount:', $json.amount);
return $input.item;

Check n8n execution logs for output.

Webhook Not Triggering​

  1. Verify URL is publicly accessible
  2. Check path matches exactly (case-sensitive)
  3. Test with: curl -X POST <webhook-url> -d '{"test": true}'
  4. Check n8n logs for incoming requests

Getting Testnet USDC​

The Mock USDC contract allows minting test tokens.

Using Basescan​

  1. Go to Mock USDC on Basescan
  2. Connect your wallet
  3. Call mint(your_address, 1000000000) (1000 USDC)

Using Code​

import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://sepolia.base.org');
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

const usdc = new ethers.Contract(
'0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb',
['function mint(address to, uint256 amount) public'],
wallet
);

await usdc.mint(wallet.address, ethers.parseUnits('1000', 6));

Contract Addresses (Base Sepolia)​

ContractAddress
ACTPKernel0x6aDB650e185b0ee77981AC5279271f0Fa6CFe7ba
EscrowVault0x921edE340770db5DB6059B5B866be987d1b7311F
Mock USDC0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb

Next Steps​

Now that you have n8n integrated:


Resources​


Questions? Open an issue on GitHub