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
Navigate to the Settings page in your LeadShark dashboard
Locate the "Webhook Settings" section
Click "Show Webhooks" to view existing webhooks or add a new one
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"
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/jsonX-Webhook-Signature: HMAC SHA-256 signature of the payloadX-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
Verify the webhook signature (although this is not mandatory)
Implement proper error handling for your webhook endpoint
Process webhooks asynchronously
Respond quickly (within 10 seconds) to webhook requests
Store the webhook secret securely (as an .env variable)
Troubleshooting
If you're not receiving webhooks:
Verify your webhook URL is accessible from the internet
Check your server logs for any errors
Ensure your endpoint responds with a 2xx status code
Verify the webhook signature is being validated correctly
Need help? Contact LeadShark support ([email protected]) for assistance.
Last updated