n8n Integration

Build automated workflows with MCP Factory using n8n.

Overview

n8n is a powerful workflow automation tool. Integrate MCP Factory to trigger campaigns from any event and receive results via webhooks.

Authentication Setup

Create an HTTP Header Auth credential in n8n:

  1. Go to Credentials → Add Credential
  2. Select Header Auth
  3. Set Name: Authorization
  4. Set Value: Bearer mcpf_live_xxxx

Create a Campaign

Use the HTTP Request node to launch a campaign:

Method: POST
URL: https://api.mcpfactory.org/campaigns
Headers:
  Content-Type: application/json
Body:
{
  "mcp": "sales-outreach",
  "target_url": "{{ $json.website }}",
  "target_audience": "{{ $json.audience }}",
  "budget": {
    "max_daily_usd": 10
  },
  "schedule": {
    "frequency": "daily",
    "trial_days": 5
  },
  "reporting": {
    "webhook_url": "https://your-n8n-instance.com/webhook/xxx"
  }
}

Receive Webhook Events

Create a Webhook trigger node to receive campaign updates:

// Incoming webhook payload
{
  "event": "campaign.milestone",
  "campaign_id": "camp_abc123",
  "data": {
    "milestone": "100_emails_sent",
    "stats": {
      "emails_sent": 100,
      "delivered": 94,
      "opened": 21,
      "replied": 3
    }
  }
}

Available Webhook Events

EventDescription
campaign.startedCampaign has started
campaign.milestoneReached a milestone (100, 500, 1000 emails)
campaign.pausedCampaign was paused
campaign.completedCampaign finished
campaign.budget_warning80% of budget used
campaign.budget_exceededBudget limit reached
reply.receivedSomeone replied to an email
meeting.bookedA meeting was booked

Example Workflow: CRM Integration

Automatically add leads who reply to your CRM:

  1. Webhook Trigger - Receive reply.received events
  2. IF Node - Check if reply is positive
  3. HTTP Request - Create lead in HubSpot/Salesforce
  4. Slack - Notify sales team
// Example: reply.received webhook payload
{
  "event": "reply.received",
  "campaign_id": "camp_abc123",
  "data": {
    "email": "john@prospect.com",
    "name": "John Smith",
    "company": "Prospect Inc",
    "reply_sentiment": "positive",
    "reply_preview": "Thanks for reaching out! I'd love to schedule a call..."
  }
}

Example Workflow: Daily Report to Slack

  1. Schedule Trigger - Every day at 9 AM
  2. HTTP Request - GET /campaigns/:id/stats
  3. Slack - Post summary to #sales channel

Get Campaign Stats

Method: GET
URL: https://api.mcpfactory.org/campaigns/{{ $json.campaign_id }}/stats

Response:
{
  "campaign_id": "camp_abc123",
  "status": "running",
  "stats": {
    "emails_sent": 247,
    "delivered": 231,
    "opened": 54,
    "replied": 12,
    "meetings_booked": 3
  },
  "costs": {
    "total_byok_usd": 4.23
  }
}

Pause/Resume Campaigns

// Pause
POST https://api.mcpfactory.org/campaigns/{{ $json.campaign_id }}/pause

// Resume
POST https://api.mcpfactory.org/campaigns/{{ $json.campaign_id }}/resume