--- title: "n8n Workflows Index" description: "Index of production n8n workflows including Ko-fi to Paper Dynasty pack distribution and Claude agent Discord notifications. Covers documentation structure, prerequisites, monitoring schedule, and security considerations." type: context domain: productivity tags: [n8n, workflows, ko-fi, paper-dynasty, claude-agent, discord, index] --- # n8n Workflows Documentation Collection of production n8n workflows and integration guides. ## Available Workflows ### Claude Agent Done β†’ Discord **Status:** Production Ready **Purpose:** Discord notification when a Claude Code subagent finishes **Quick Links:** - πŸ“– **[claude-agent-notifications.md](claude-agent-notifications.md)** - Setup guide and payload reference - πŸ“¦ **[claude-agent-done.json](claude-agent-done.json)** - Importable n8n workflow **Features:** - Triggered by Claude Code's `SubagentStop` HTTP hook - Extracts agent name from the event payload - Posts a completion message to Discord - Discord webhook URL kept in n8n variables (not local config) **Webhook URL:** - Test: `http://10.10.0.210:5678/webhook-test/claude-agent-done` - Production: `http://10.10.0.210:5678/webhook/claude-agent-done` --- ### Ko-fi β†’ Paper Dynasty Integration **Status:** Production Ready **Purpose:** Automated pack distribution for Ko-fi shop purchases **Quick Links:** - πŸš€ **[QUICK-START.md](QUICK-START.md)** - Get running in 30 minutes - πŸ“– **[kofi-paper-dynasty.md](kofi-paper-dynasty.md)** - Complete setup guide and node configuration - πŸ§ͺ **[kofi-testing-guide.md](kofi-testing-guide.md)** - Testing procedures and sample payloads - πŸ—ΊοΈ **[kofi-product-mapping-template.json](kofi-product-mapping-template.json)** - Product configuration template - πŸ“ **[kofi-implementation-notes.md](kofi-implementation-notes.md)** - Real implementation, gotchas, and lessons learned **Features:** - Receives Ko-fi webhooks securely - Multi-method user identification (discord_userid or team abbrev) - Flexible product mapping system - Paper Dynasty API integration - Discord notifications for all outcomes - Comprehensive error handling - Manual review workflow for edge cases **Webhook URLs:** - Test: `https://n8n.manticorum.com/webhook-test/kofi-paperdy` - Production: `https://n8n.manticorum.com/webhook/kofi-paperdy` --- ## Documentation Structure ### Quick Start Guide **File:** `QUICK-START.md` **Audience:** First-time setup **Time:** 30 minutes **Contents:** - Prerequisites checklist - Step-by-step setup (8 steps) - Post-setup tasks - Quick troubleshooting ### Complete Setup Guide **File:** `kofi-paper-dynasty.md` **Audience:** Detailed implementation **Contents:** - Architecture overview - Prerequisites and configuration - Node-by-node workflow setup - Discord notification templates - Troubleshooting guide - Monitoring and maintenance ### Testing Guide **File:** `kofi-testing-guide.md` **Audience:** QA and validation **Contents:** - 5-phase testing strategy - 8 test scenarios with cURL commands - Validation scripts - Testing checklist - Production monitoring ### Product Mapping Template **File:** `kofi-product-mapping-template.json` **Audience:** Configuration reference **Contents:** - JSON structure for n8n custom variable - Example product configurations - Pack type reference - Naming conventions - Usage examples --- ## Getting Started ### New to Ko-fi Integration? 1. **Start here:** [QUICK-START.md](QUICK-START.md) 2. **Need details?** [kofi-paper-dynasty.md](kofi-paper-dynasty.md) 3. **Ready to test?** [kofi-testing-guide.md](kofi-testing-guide.md) ### Adding New Products? 1. Open [kofi-product-mapping-template.json](kofi-product-mapping-template.json) 2. Copy an existing product configuration 3. Update Ko-fi product code and pack details 4. Add to n8n custom variable `KOFI_PRODUCT_MAP` 5. Create matching product in Ko-fi shop 6. Test with cURL before going live ### Troubleshooting? **Quick Fixes:** - Webhook 404: Check workflow is Active in n8n - Token error: Verify Ko-fi token in n8n credential - Team not found: Check discord_userid or message field - Packs not granted: Review API response in execution log **Detailed Help:** - Full troubleshooting: `kofi-paper-dynasty.md` β†’ Troubleshooting section - Test scenarios: `kofi-testing-guide.md` β†’ Common Issues - Quick reference: `QUICK-START.md` β†’ Troubleshooting --- ## Workflow Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Ko-fi Shop Order β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ POST webhook ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ n8n Webhook: /webhook/kofi-paperdy β”‚ β”‚ - Parse form data β”‚ β”‚ - Validate Ko-fi token β”‚ β”‚ - Filter shop orders only β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Identify Paper Dynasty Team β”‚ β”‚ β€’ discord_userid β†’ gmid lookup β”‚ β”‚ β€’ OR message field β†’ team abbrev β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Team Found? β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ Yes ↓ ↓ No β”‚ └──→ Manual Review Discord Notification ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Map Ko-fi Products β†’ Paper Dynasty Packs β”‚ β”‚ β€’ Load KOFI_PRODUCT_MAP variable β”‚ β”‚ β€’ Map shop_items to pack requests β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Call Paper Dynasty API: POST /packs β”‚ β”‚ β€’ Grant packs to team β”‚ β”‚ β€’ Auto-retry on failure (3x) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ API Success? β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ Yes ↓ ↓ No β”‚ └──→ Error Discord Notification ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Success Discord Notification β”‚ β”‚ β€’ Customer name and team β”‚ β”‚ β€’ Packs granted β”‚ β”‚ β€’ Transaction ID β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ Return 200 OK to Ko-fi ``` --- ## Prerequisites ### System Requirements - n8n instance running at `https://n8n.manticorum.com` - PostgreSQL database for execution history - HTTPS access via Nginx Proxy Manager - WebSocket support enabled ### Required Credentials 1. **Ko-fi Verification Token** - Source: Ko-fi dashboard β†’ Settings β†’ API β†’ Webhooks - Format: UUID (e.g., `8c2a3835-4544-4f27-a53a-adfd1fcc5664`) - Security: Validates webhook authenticity 2. **Paper Dynasty API Key** - Source: Paper Dynasty admin - Format: Bearer token - Permissions: Read teams, write packs 3. **Discord Webhook URL** - Source: Discord channel β†’ Integrations β†’ Webhooks - Format: `https://discord.com/api/webhooks/...` - Purpose: Success/error/manual review notifications ### Required Custom Variables 1. **KOFI_PRODUCT_MAP** - Type: JSON object - Location: n8n β†’ Settings β†’ Variables - Purpose: Map Ko-fi product codes to PD packs - Template: `kofi-product-mapping-template.json` --- ## Monitoring & Maintenance ### Daily Monitoring - βœ… Check Discord for notifications - βœ… Review failed executions in n8n - βœ… Verify packs granted correctly ### Weekly Tasks - πŸ“Š Review n8n execution statistics - πŸ” Check for unknown product codes - πŸ“ Update product mapping if needed - πŸ§ͺ Test new products before launch ### Monthly Tasks - πŸ’Ύ Backup n8n database - πŸ” Rotate Ko-fi verification token - πŸ”‘ Rotate Paper Dynasty API key - πŸ“– Update documentation with lessons learned ### Quarterly Tasks - πŸ”§ Optimize workflow performance - πŸ“ˆ Review transaction analytics - πŸ›‘οΈ Security audit (credentials, access logs) - πŸ§ͺ Test disaster recovery procedure --- ## Support & Resources ### Internal Documentation - **n8n Infrastructure:** `/productivity/n8n/CONTEXT.md` - **n8n Troubleshooting:** `/productivity/n8n/troubleshooting.md` - **Paper Dynasty API:** `/home/cal/.claude/skills/paper-dynasty/SKILL.md` ### External Resources - **n8n Documentation:** https://docs.n8n.io/ - **Ko-fi Webhook API:** https://help.ko-fi.com/hc/en-us/articles/360004162298 - **n8n Community:** https://community.n8n.io/ - **n8n Webhook Templates:** https://n8n.io/workflows/?categories=Webhooks ### Getting Help 1. **Check execution logs:** n8n β†’ Executions β†’ Filter by workflow 2. **Review Discord notifications:** Look for error details and transaction IDs 3. **Test with cURL:** Isolate webhook vs API vs n8n issues 4. **Consult troubleshooting guides:** Each doc has troubleshooting section 5. **Manual intervention:** Use Discord notifications to process failed orders --- ## Security Considerations ### Webhook Security βœ… **Token Validation:** All webhooks validated against Ko-fi verification token βœ… **HTTPS Only:** All communication encrypted via NPM SSL βœ… **Rate Limiting:** Configure in NPM for webhook endpoints βœ… **Path Obfuscation:** Use non-obvious webhook paths ### Credential Management βœ… **Encrypted Storage:** n8n encrypts credentials with N8N_ENCRYPTION_KEY βœ… **No Hardcoding:** Never hardcode secrets in workflows βœ… **Regular Rotation:** Quarterly rotation schedule for tokens βœ… **Backup Security:** Store encryption key in password manager ### Data Privacy βœ… **PII Handling:** Minimize customer data in logs and notifications βœ… **Retention Policy:** Auto-delete old executions (30 days) βœ… **Sanitized Logging:** Remove sensitive fields from error logs βœ… **GDPR Compliance:** Data deletion mechanism available --- ## Contributing ### Adding New Workflows 1. Create workflow documentation (follow `kofi-paper-dynasty.md` structure) 2. Add testing guide with sample payloads 3. Update this README with workflow description 4. Create quick-start guide if complex 5. Update `/productivity/n8n/CONTEXT.md` with workflow details ### Documentation Standards - **Markdown format** for all docs - **Code blocks** with language syntax highlighting - **cURL examples** for all webhook tests - **Screenshots** where helpful (workflow diagrams) - **Version history** in Change Log section ### Testing Requirements - βœ… Test with simulated webhooks (cURL) - βœ… Test with real data in `/webhook-test/` path - βœ… Validate all error paths - βœ… Verify Discord notifications - βœ… Test edge cases and invalid data --- ## Change Log ### 2025-11-13 - Ko-fi Integration - Added Ko-fi β†’ Paper Dynasty workflow - Created comprehensive documentation suite - Implemented multi-method user identification - Added Discord notification system - Created testing guide with 8 scenarios - Documented product mapping system --- ## License & Attribution **n8n:** Fair-code licensed (n8n GmbH) **Workflows:** Created by Cal Corum for Paper Dynasty **Documentation:** MIT License --- **Questions?** Consult the [QUICK-START.md](QUICK-START.md) guide or review workflow-specific documentation.