How to Use Webhooks to Connect Any App with Web3Forms
Need to send form data to a custom application or CRM? Web3Forms webhooks let you connect to virtually any service that accepts HTTP requests. Whether it's Zapier, Make, HubSpot, or your own backend, webhooks make it possible.
In this comprehensive guide, we'll show you how to use webhooks to extend Web3Forms functionality.
What Are Webhooks?
Webhooks are automated HTTP requests sent when an event occurs. When someone submits your form, Web3Forms sends a POST request to your specified URL with all the form data as JSON.
Think of webhooks as a "push notification" for your server - instead of constantly checking for new submissions, your server receives them automatically.
Why Use Webhooks?
- Universal Compatibility: Connect to any service that accepts HTTP requests
- Custom Processing: Build your own submission handling logic
- Third-Party Integrations: Connect to Zapier, Make, n8n, and more
- CRM Integration: Send leads directly to HubSpot, Salesforce, etc.
- Database Storage: Save submissions to your own database
- Email Marketing: Add contacts to Mailchimp, ConvertKit, etc.
Prerequisites
Before you start:
- A Web3Forms account (Starter plan or higher)
- A webhook endpoint URL
- A form already set up with Web3Forms
Setting Up Webhooks
Step 1: Create Your Webhook Endpoint
First, you need a URL to receive the webhook data. Options include:
Option A: Use an Automation Platform
Zapier:
- Create a new Zap
- Choose "Webhooks by Zapier" as the trigger
- Select "Catch Hook"
- Copy the webhook URL provided
Make (formerly Integromat):
- Create a new scenario
- Add "Webhooks" module
- Select "Custom webhook"
- Copy the webhook URL
n8n:
- Create a new workflow
- Add "Webhook" node
- Copy the test/production URL
Option B: Use Your Own Backend
Create an endpoint in your backend:
// Node.js / Express example
app.post('/webhook/web3forms', (req, res) => {
const formData = req.body;
console.log('New submission:', formData);
// Process the data...
res.status(200).json({ success: true });
});
Step 2: Configure Webhook in Web3Forms
- Log in to your Web3Forms Dashboard
- Select the form you want to connect
- Go to the Integrations tab
- Click on Webhooks
- Enter your webhook URL
- Click Save
Step 3: Test Your Webhook
- Submit a test form
- Check your endpoint received the data
- Verify the JSON structure
Webhook Payload Structure
Here's the JSON payload Web3Forms sends:
{
"name": "John Smith",
"email": "[email protected]",
"phone": "(555) 123-4567",
"message": "Hello, I'm interested in...",
"attachments": [
{
"filename": "attachment.pdf",
"url": "https://api.web3forms.com/download?file=attachment.pdf"
}
],
}
All form fields are included as top-level properties.
Advanced Configuration
Webhook Security
Protect your webhook endpoint:
- Use HTTPS: Always use secure URLs
- Verify requests: Check for expected headers or signatures
- Validate data: Sanitize incoming data
- Rate limiting: Protect against abuse
Integration Examples
Zapier Workflow
Create a Zap that:
- Trigger: Webhooks by Zapier (Catch Hook)
- Action 1: Google Sheets (Add Row)
- Action 2: Gmail (Send Email)
- Action 3: Slack (Send Message)
HubSpot Integration
Send leads to HubSpot CRM:
app.post('/webhook/web3forms', async (req, res) => {
const { name, email, phone, message } = req.body;
await fetch('https://api.hubapi.com/contacts/v1/contact', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_HUBSPOT_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
properties: [
{ property: 'firstname', value: name },
{ property: 'email', value: email },
{ property: 'phone', value: phone },
{ property: 'message', value: message }
]
})
});
res.status(200).json({ success: true });
});
Mailchimp Integration
Add contacts to a mailing list:
app.post('/webhook/web3forms', async (req, res) => {
const { email, name } = req.body;
const [firstName, lastName] = name.split(' ');
await fetch(`https://us1.api.mailchimp.com/3.0/lists/LIST_ID/members`, {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('anystring:YOUR_API_KEY'),
'Content-Type': 'application/json'
},
body: JSON.stringify({
email_address: email,
status: 'subscribed',
merge_fields: {
FNAME: firstName,
LNAME: lastName || ''
}
})
});
res.status(200).json({ success: true });
});
Database Storage
Save to MongoDB:
app.post('/webhook/web3forms', async (req, res) => {
const submission = new Submission({
...req.body,
receivedAt: new Date()
});
await submission.save();
res.status(200).json({ success: true });
});
Troubleshooting
Webhook Not Receiving Data?
- Check URL: Verify the endpoint URL is correct
- Test endpoint: Use a tool like webhook.site to test
- Check firewall: Ensure your server accepts external requests
- Review logs: Check your server logs for errors
Getting Errors?
Common issues:
- 401 Unauthorized: Check authentication headers
- 404 Not Found: Verify the endpoint path
- 500 Server Error: Check your server-side code
- Timeout: Respond within 30 seconds
Data Format Issues?
Ensure your endpoint:
- Accepts POST requests
- Parses JSON body correctly
- Returns a 2xx status code
Example Form Code
Here's a form ready for webhook integration:
<form action="https://api.web3forms.com/submit" method="POST">
<input type="hidden" name="access_key" value="YOUR_ACCESS_KEY">
<input type="hidden" name="subject" value="New Lead from Website">
<!-- Bot protection -->
<input type="checkbox" name="botcheck" style="display: none;">
<div>
<label for="name">Full Name</label>
<input type="text" name="name" id="name" required>
</div>
<div>
<label for="email">Email Address</label>
<input type="email" name="email" id="email" required>
</div>
<div>
<label for="company">Company</label>
<input type="text" name="company" id="company">
</div>
<div>
<label for="budget">Budget Range</label>
<select name="budget" id="budget">
<option value="<5k">Less than $5,000</option>
<option value="5k-10k">$5,000 - $10,000</option>
<option value="10k-25k">$10,000 - $25,000</option>
<option value=">25k">More than $25,000</option>
</select>
</div>
<div>
<label for="message">Project Details</label>
<textarea name="message" id="message" rows="4" required></textarea>
</div>
<button type="submit">Submit Inquiry</button>
</form>
Best Practices
- Always respond quickly: Return a response within seconds
- Process asynchronously: Queue heavy tasks for background processing
- Log everything: Keep records for debugging
- Handle failures gracefully: Implement retry logic
- Secure your endpoints: Use authentication and HTTPS
Wrapping Up
Webhooks open up endless possibilities for form data processing. Whether you're building custom workflows, integrating with CRMs, or creating automated pipelines, webhooks give you complete control over your form submissions.
Ready to get started? Create your Web3Forms account and set up webhooks today!
Related Articles: