n8n-nodes-web-push
v0.1.1
Published
N8N community node for sending Web Push notifications
Downloads
90
Maintainers
Keywords
Readme
Web Push Node
This is an n8n community node that lets you send Web Push notifications in your n8n workflows.
Web Push is a standardized protocol that allows you to send push notifications directly to users' browsers, even when they're not actively using your website. This node enables you to integrate push notifications into your automation workflows, making it perfect for real-time alerts, updates, and engagement campaigns.
n8n is a fair-code licensed workflow automation platform.
Installation
Follow the installation guide in the n8n community nodes documentation.
Community Node Installation
- Go to Settings > Community Nodes in your n8n instance
- Select Install
- Enter
n8n-nodes-web-pushin the Enter npm package name field - Agree to the risks and select Install
Alternatively, install via npm in your n8n installation directory:
npm install n8n-nodes-web-pushOperations
This node supports sending Web Push notifications with the following capabilities:
Send Push Notification
Sends a push notification to a subscribed user's browser.
Required Parameters:
- Endpoint: The push subscription endpoint URL from the user's browser subscription
- Auth: The authentication secret from the push subscription
- P256dh: The P256dh public key from the push subscription
- Payload: The notification message/data to send
Optional Parameters:
- TTL (Time To Live): How long the push service should attempt to deliver the message (default: 4 weeks)
- Urgency: Priority level of the notification (
very-low,low,normal, orhigh) - Topic: Categorization identifier for the notification (max 32 characters)
- Timeout: Request timeout in milliseconds (default: 30000)
Credentials
This node uses VAPID (Voluntary Application Server Identification) for authentication, which is the standard way to identify your application server to push services.
Prerequisites
- Generate VAPID keys for your application. You can do this using the
web-pushnpm package:
npx web-push generate-vapid-keysThis will output a public and private key pair that you'll use for authentication.
- Set up a push subscription in your web application using the Push API and Service Workers
Setting Up VAPID Credentials
- In n8n, go to Credentials > New
- Search for "VAPID API" and select it
- Fill in the following fields:
- Subject: A contact URI for your application (e.g.,
mailto:[email protected]orhttps://yourdomain.com) - Public Key: Your VAPID public key (base64url-encoded)
- Private Key: Your VAPID private key (base64url-encoded)
- GCM API Key (optional): Google Cloud Messaging API key for backward compatibility with older Chrome versions
- Subject: A contact URI for your application (e.g.,
- Click Create
Getting Push Subscription Details
To send notifications, you need the subscription details from your users' browsers. In your web application:
// Example: Get push subscription from browser
const registration = await navigator.serviceWorker.ready;
const subscription = await registration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: 'YOUR_VAPID_PUBLIC_KEY',
});
// subscription.endpoint - Use for "Endpoint" parameter
// subscription.keys.auth - Use for "Auth" parameter
// subscription.keys.p256dh - Use for "P256dh" parameterStore these subscription details in your database and use them in your n8n workflow.
Compatibility
- Minimum n8n version: 0.198.0
- Tested with: n8n 1.0.0+
- Node version: Requires Node.js 18+
This node uses the web-push library v3.6.7 which supports:
- Chrome 50+
- Firefox 44+
- Edge 17+
- Safari 16+ (macOS 13+, iOS 16.4+)
- Opera 37+
Usage
Basic Example
Here's a simple workflow to send a push notification:
- Add the Web Push node to your workflow
- Configure credentials: Select or create VAPID API credentials
- Set subscription details:
- Endpoint:
{{ $json.subscription.endpoint }} - Auth:
{{ $json.subscription.keys.auth }} - P256dh:
{{ $json.subscription.keys.p256dh }}
- Endpoint:
- Set payload: Enter your notification message or use JSON data
Example Workflow Scenarios
User Registration Notification
Trigger: Webhook (new user signup)
→ Database: Store user subscription
→ Web Push: Send welcome notificationAlert System
Trigger: Schedule/Cron
→ HTTP Request: Check system status
→ IF: Status is down
→ Web Push: Send alert to admin subscriptionsBreaking News Updates
Trigger: RSS Feed
→ Database: Get all subscribed users
→ Split In Batches
→ Web Push: Send notification to each subscriberImportant Notes
- Payload Format: The payload should be a string. If you want to send structured data, stringify your JSON first
- Service Workers Required: Users must have a service worker registered in their browser to receive notifications
- HTTPS Required: Web Push only works on HTTPS websites (or localhost for development)
- User Permissions: Users must grant notification permissions in their browser
- Subscription Management: Store and manage user subscriptions in your own database
- Error Handling: Handle expired or invalid subscriptions gracefully (410/404 responses mean the subscription is no longer valid)
Notification Payload Best Practices
When sending notifications, keep these tips in mind:
- Keep messages concise and actionable
- Include relevant information in the payload
- Use urgency levels appropriately (reserve
highfor critical alerts) - Set reasonable TTL values based on message relevance
- Test notifications across different browsers
Troubleshooting
"Invalid subscription" errors:
- The subscription may have expired or been unsubscribed
- Remove invalid subscriptions from your database when you receive 410 Gone responses
"Unauthorized" errors:
- Check that your VAPID keys are correct
- Ensure the public key used in the browser matches your credentials
"Endpoint not found" errors:
- The push service endpoint may have changed
- Request users to re-subscribe
Resources
- n8n community nodes documentation
- Web Push Protocol (RFC 8030)
- VAPID Specification (RFC 8292)
- MDN Web Push API
- web-push library documentation
- Google Web Push Guide
