Webhooks

Webhooks can be used to push leads generated from LeadShark to external systems. (CRM solutions, email sending software etc.)

Webhooks

Overview

LeadShark's webhook system allows you to receive real-time updates about generated leads and automation activities. When a lead is successfully processed through your automation, LeadShark will send a POST request to your specified URL with detailed information about the lead.

Setting Up Webhooks

  1. Navigate to the Settings page in your LeadShark dashboard

  2. Locate the "Webhook Settings" section

  3. Click "Show Webhooks" to view existing webhooks or add a new one

  4. To add a webhook:

    • Enter a name for your webhook (e.g., "CRM Integration")

    • Enter the URL where you want to receive webhook events

    • Click "Add Webhook"

  5. Use Test webhook button (this will send a GET request with the test payload)

Webhook Security

Each webhook is created with a unique secret key. This secret is used to sign the payload, allowing you to verify that the webhook came from LeadShark. The signature is included in the X-Webhook-Signature header.

Payload Format

When a lead is processed, you'll receive a POST request with this JSON structure:

{
"event": "dm.sent",
"timestamp": "2024-03-21T15:30:00Z",
"data": {
"lead": {
"name": "John Doe",
"first_name": "John",
"title": "Software Engineer",
"linkedin_url": "https://linkedin.com/in/johndoe",
"linkedin_username": "johndoe",
"connection_status": "Connected",
"commenter_id": "abc123"
},
"message": "Hello John, thanks for your comment...",
"automation": {
"id": "automation_123",
"name": "Product Launch Campaign"
},
"post_id": "post_123"
}
}

Headers

Each webhook request includes these headers:

  • Content-Type: application/json

  • X-Webhook-Signature: HMAC SHA-256 signature of the payload

  • X-Webhook-Event: Event type (e.g., "dm.sent")

Verifying Webhooks

To verify that a webhook came from LeadShark, compute the HMAC SHA-256 signature using your webhook secret:

const crypto = require('crypto');
const signature = crypto
.createHmac('sha256', webhookSecret)
.update(JSON.stringify(payload))
.digest('hex');
const isValid = signature === request.headers['x-webhook-signature'];

Best Practices

  1. Verify the webhook signature (although this is not mandatory)

  2. Implement proper error handling for your webhook endpoint

  3. Process webhooks asynchronously

  4. Respond quickly (within 10 seconds) to webhook requests

  5. Store the webhook secret securely (as an .env variable)

Troubleshooting

If you're not receiving webhooks:

  1. Verify your webhook URL is accessible from the internet

  2. Check your server logs for any errors

  3. Ensure your endpoint responds with a 2xx status code

  4. Verify the webhook signature is being validated correctly

Need help? Contact LeadShark support ([email protected]) for assistance.

Last updated