lokicms-plugin-webhooks
v1.0.0
Published
Outbound webhooks plugin for LokiCMS - Send HTTP notifications on CMS events
Maintainers
Readme
Webhooks Plugin for LokiCMS
Send HTTP webhooks when events occur in LokiCMS. Compatible with n8n, Zapier, Make, and any webhook receiver.
Features
- Event-driven: Trigger webhooks on content and user events
- Multiple endpoints: Configure different URLs for different events
- Content type filtering: Only trigger for specific content types
- HMAC signatures: Secure webhooks with SHA-256 signatures
- Custom headers: Add authentication or custom headers
- Automatic retries: Configurable retry on failure
- Delivery logs: Track all webhook deliveries
- MCP tools: AI-accessible webhook management
Installation
npm install lokicms-plugin-webhooksConfiguration
Add to plugins.json:
{
"name": "webhooks",
"enabled": true,
"source": "npm",
"package": "lokicms-plugin-webhooks",
"settings": {
"maxRetries": 3,
"retryDelay": 5000,
"timeout": 30000
}
}Supported Events
| Event | Description |
|-------|-------------|
| entry:afterCreate | Content entry created |
| entry:afterUpdate | Content entry updated |
| entry:afterDelete | Content entry deleted |
| entry:afterPublish | Content entry published |
| entry:afterUnpublish | Content entry unpublished |
| user:afterCreate | User account created |
| user:afterUpdate | User account updated |
| user:afterDelete | User account deleted |
| media:afterUpload | Media file uploaded |
| media:afterDelete | Media file deleted |
API Endpoints
Base path: /api/plugins/webhooks
Endpoints Management
# List all endpoints
GET /endpoints
# Get endpoint details
GET /endpoints/:id
# Create endpoint
POST /endpoints
{
"name": "n8n Workflow",
"url": "https://n8n.example.com/webhook/abc123",
"events": ["entry:afterCreate", "entry:afterUpdate"],
"secret": "my-secret-key",
"headers": {
"X-Custom-Header": "value"
},
"enabled": true,
"contentTypeFilter": ["post", "page"]
}
# Update endpoint
PUT /endpoints/:id
# Delete endpoint
DELETE /endpoints/:id
# Test endpoint
POST /endpoints/:id/testDeliveries & Events
# List delivery logs
GET /deliveries
GET /deliveries?endpointId=xxx&status=failed&limit=50
# List supported events
GET /events
# Reload endpoints (after manual changes)
POST /reloadWebhook Payload
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"event": "entry:afterCreate",
"timestamp": 1703980800000,
"contentType": "post",
"data": {
"id": "abc123",
"title": "My Post",
"slug": "my-post",
"content": { ... },
"status": "published",
"createdAt": 1703980800000
}
}Webhook Headers
Every webhook request includes:
| Header | Description |
|--------|-------------|
| Content-Type | application/json |
| User-Agent | LokiCMS-Webhooks/1.0 |
| X-Webhook-ID | Unique delivery ID |
| X-Webhook-Event | Event name |
| X-Webhook-Timestamp | Unix timestamp |
| X-Webhook-Signature | HMAC-SHA256 signature (if secret configured) |
Signature Verification
If you configure a secret, the plugin signs payloads with HMAC-SHA256:
// Node.js verification example
const crypto = require('crypto');
function verifySignature(payload, signature, secret) {
const expected = 'sha256=' + crypto
.createHmac('sha256', secret)
.update(JSON.stringify(payload))
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}
// Express middleware
app.post('/webhook', (req, res) => {
const signature = req.headers['x-webhook-signature'];
if (!verifySignature(req.body, signature, 'your-secret')) {
return res.status(401).send('Invalid signature');
}
// Process webhook...
});n8n Integration
- In n8n, create a new workflow with a Webhook trigger
- Copy the webhook URL (e.g.,
https://n8n.example.com/webhook/abc123) - Create endpoint in LokiCMS:
curl -X POST http://localhost:3005/api/plugins/webhooks/endpoints \
-H "Content-Type: application/json" \
-d '{
"name": "n8n Content Updates",
"url": "https://n8n.example.com/webhook/abc123",
"events": ["entry:afterCreate", "entry:afterUpdate", "entry:afterDelete"],
"enabled": true
}'Zapier Integration
- Create a Zap with Webhooks by Zapier trigger
- Choose "Catch Hook" and copy the webhook URL
- Create endpoint in LokiCMS with the Zapier URL
MCP Tools
Available tools for AI agents:
| Tool | Description |
|------|-------------|
| webhooks_create_webhook | Create a new endpoint |
| webhooks_update_webhook | Update an endpoint |
| webhooks_delete_webhook | Delete an endpoint |
| webhooks_test_webhook | Test an endpoint |
| webhooks_list_webhooks | List all endpoints |
| webhooks_list_deliveries | View delivery logs |
| webhooks_list_webhook_events | List supported events |
Content Types
The plugin creates these content types:
webhooks-webhook-endpoint- Endpoint configurationswebhooks-webhook-delivery- Delivery logs
License
MIT
