Activepieces Integration
Monetize your Activepieces flows using xpay Pay-to-Run webhooks.
Overview
Activepieces is an open-source automation platform with a clean interface and powerful capabilities. With xpay, you can:
- Accept USDC payments before flow execution
- Collect customer information via custom forms
- Trigger any Activepieces flow after payment
Setup Guide
Step 1: Create a Webhook Trigger in Activepieces
- Open Activepieces and create a new flow
- Add the Webhook trigger
- Select Catch Request
- Copy the generated webhook URL
Step 2: Create an xpay Checkout
-
Go to xpay Dashboard
-
Create a new checkout:
- Product Name: Your flow’s name
- Price: Amount to charge in USDC
- Callback URL: Your Activepieces webhook URL
- Network: Base Sepolia (testnet) or Base (mainnet)
- Recipient Wallet: Your wallet address
-
Add form fields for customer information
-
Save your checkout
Step 3: Build Your Flow
After the webhook trigger, add your flow logic. The webhook data structure:
{
"payment": {
"tx_hash": "0x...",
"payer_address": "0x...",
"amount": 5.00,
"currency": "USDC",
"network": "base",
"timestamp": 1703001234567
},
"customer_input": {
"email": "customer@example.com",
"prompt": "Generate a blog post about AI"
},
"metadata": {
"checkout_id": "chk_abc123",
"test_mode": false
}
}Example Flow: AI Content Generator
[Webhook] → [OpenAI: Generate] → [Gmail: Send Result]-
Webhook Trigger
- Receives payment confirmation from xpay
-
OpenAI Piece
- Use
{{trigger.body.customer_input.prompt}}as input - Generate content based on customer request
- Use
-
Gmail Piece
- Send to
{{trigger.body.customer_input.email}} - Include generated content
- Send to
Signature Verification (Optional)
For production flows, verify webhook authenticity:
- Add a Code piece after the webhook trigger
- Use this JavaScript:
const crypto = require('crypto');
const signature = inputs.headers['x-xpay-signature'];
const timestamp = inputs.headers['x-xpay-timestamp'];
const body = inputs.body;
const secret = 'YOUR_WEBHOOK_SECRET'; // Store in flow variables
const data = `${timestamp}.${JSON.stringify(body)}`;
const expected = 'sha256=' + crypto
.createHmac('sha256', secret)
.update(data)
.digest('hex');
if (signature !== expected) {
throw new Error('Invalid signature');
}
return body;Flow Templates
Template 1: PDF Generator
Accept payment, generate PDF from customer data, email result.
[Webhook] → [Code: Build PDF] → [Gmail: Send PDF]Template 2: API Access
Accept payment, provide temporary API key or access token.
[Webhook] → [Code: Generate Key] → [HTTP: Store in DB] → [Gmail: Send Key]Template 3: Data Analysis
Accept payment with file upload, analyze data, return insights.
[Webhook] → [OpenAI: Analyze] → [Airtable: Store] → [Gmail: Send Report]Testing Your Flow
- In Activepieces, use Test Flow to simulate webhooks
- In xpay dashboard, click Test Webhook to send a test payload
- Verify data flows through each piece correctly
Tips for Production
Handle Errors Gracefully
Add error handling pieces:
- Branch piece for conditional logic
- HTTP Request piece to notify xpay of failures
Use Variables
Store sensitive data like webhook secrets in Activepieces variables:
- Go to Project Settings → Variables
- Add
XPAY_WEBHOOK_SECRET - Reference as
{{vars.XPAY_WEBHOOK_SECRET}}
Logging
Add logging for debugging:
- Use HTTP Request piece to send to a logging service
- Or use Airtable/Google Sheets to log transactions
Troubleshooting
Flow not triggering
- Ensure flow is published and enabled
- Check webhook URL matches exactly in xpay dashboard
- Look at Activepieces run history for errors
Missing data
- Check you’re accessing
trigger.bodynot justtrigger - Verify customer form fields match expected names
- Use Code piece to inspect raw payload
Timeouts
Activepieces webhooks timeout after 30 seconds. For long flows:
- Return response immediately
- Use Delay piece with retries for external services