> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendpilot.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Zapier Integration

> Connect SendPilot to 5,000+ apps with Zapier

Zapier allows you to connect SendPilot with thousands of apps including Salesforce, HubSpot, Slack, Google Sheets, and more — all without writing any code.

## Overview

With Zapier, you can:

* **Triggers**: React to SendPilot events (lead replies, connections, status changes)
* **Actions**: Control SendPilot from other apps (add leads, update status, send messages)

## Setting Up SendPilot in Zapier

### Step 1: Create a Webhook Trigger

1. Create a new Zap in Zapier
2. Select **Webhooks by Zapier** as the trigger app
3. Choose **Catch Hook** as the trigger event
4. Copy the webhook URL provided by Zapier

### Step 2: Register Webhook in SendPilot

1. Go to SendPilot **Integrations** → **Webhooks**
2. Click **Add Webhook**
3. Paste your Zapier webhook URL
4. Select the events you want to trigger on (e.g., `message.received`)
5. Save the webhook

### Step 3: Test the Connection

1. In Zapier, click **Test trigger**
2. Trigger an event in SendPilot (e.g., simulate a reply)
3. Zapier will capture the test data

## Common Zapier Workflows

### 1. New Reply → Slack Notification

When a lead replies, notify your sales team instantly.

```
Trigger: Webhooks by Zapier (Catch Hook)
  ↓
Filter: Event Type = "message.received"
  ↓
Action: Slack - Send Channel Message
  - Channel: #sales-leads
  - Message: "🎉 New reply from {{linkedinUrl}}!"
```

### 2. New Reply → HubSpot Task

Create a follow-up task when a lead engages.

```
Trigger: Webhooks by Zapier (Catch Hook)
  ↓
Filter: Event Type = "message.received"
  ↓
Action: HubSpot - Create Task
  - Title: "Follow up with LinkedIn lead"
  - Due Date: Tomorrow
  - Notes: "Lead replied: {{replyPreview}}"
```

### 3. Form Submission → Add Lead to Campaign

Add leads from your website form to a SendPilot campaign.

```
Trigger: Typeform - New Entry
  ↓
Action: Webhooks by Zapier - POST
  - URL: https://api.sendpilot.ai/v1/leads
  - Headers: X-API-Key: YOUR_API_KEY
  - Body: {
      "campaignId": "your_campaign_id",
      "leads": [{
        "linkedinUrl": "{{linkedin_url_field}}",
        "firstName": "{{first_name}}",
        "email": "{{email}}"
      }]
    }
```

### 4. Connection Accepted → CRM Update

Update your CRM when a lead accepts your connection.

```
Trigger: Webhooks by Zapier (Catch Hook)
  ↓
Filter: Event Type = "connection.accepted"
  ↓
Action: Salesforce - Update Record
  - Object: Lead
  - Find by: LinkedIn URL
  - Status: "Connected"
```

### 5. Lead Status Changed → Google Sheet Log

Log all lead activity to a spreadsheet.

```
Trigger: Webhooks by Zapier (Catch Hook)
  ↓
Filter: Event Type = "lead.status.changed"
  ↓
Action: Google Sheets - Create Row
  - Lead ID: {{leadId}}
  - LinkedIn URL: {{linkedinUrl}}
  - Previous Status: {{previousStatus}}
  - New Status: {{newStatus}}
  - Timestamp: {{timestamp}}
```

## Using SendPilot API Actions

To call SendPilot API from Zapier, use **Webhooks by Zapier** (Custom Request):

### Add Leads Example

```
Action: Webhooks by Zapier - Custom Request
  Method: POST
  URL: https://api.sendpilot.ai/v1/leads
  Headers:
    X-API-Key: YOUR_API_KEY
    Content-Type: application/json
  Body (JSON):
    {
      "campaignId": "campaign_id_here",
      "leads": [
        {
          "linkedinUrl": "{{LinkedIn URL}}",
          "firstName": "{{First Name}}",
          "lastName": "{{Last Name}}",
          "company": "{{Company}}"
        }
      ]
    }
```

### Update Lead Status Example

```
Action: Webhooks by Zapier - Custom Request
  Method: PATCH
  URL: https://api.sendpilot.ai/v1/leads/{{lead_id}}/status
  Headers:
    X-API-Key: YOUR_API_KEY
    Content-Type: application/json
  Body (JSON):
    {
      "status": "REPLY_RECEIVED"
    }
```

## Best Practices

<AccordionGroup>
  <Accordion title="Use Filters">
    Add a Filter step to process only specific events. Filter by `eventType` to handle different events differently.
  </Accordion>

  <Accordion title="Handle Errors">
    Add error handling paths in your Zaps to catch API failures.
  </Accordion>

  <Accordion title="Rate Limiting">
    Zapier has its own rate limits. Use delays between actions if processing many events.
  </Accordion>

  <Accordion title="Test Thoroughly">
    Always test with real data before going live.
  </Accordion>
</AccordionGroup>

## Webhook Payload Reference

When SendPilot sends a webhook to Zapier, the payload looks like:

```json theme={null}
{
  "eventId": "evt_123456789",
  "eventType": "message.received",
  "timestamp": "2024-02-24T10:30:00.000Z",
  "workspaceId": "ws_abc123",
  "data": {
    "leadId": "lead_xyz",
    "campaignId": "camp_123",
    "linkedinUrl": "https://linkedin.com/in/john-doe",
    "replyPreview": "Thanks for reaching out..."
  }
}
```

Use these fields in your Zapier actions with the `{{field_name}}` syntax.
