Real-time event notifications through secure webhooks.
Set up a publicly accessible HTTPS endpoint to receive webhook events
Create a webhook secret to verify event authenticity
Choose which events you want to receive notifications for
Process webhook payloads and implement your business logic
Triggered when crop analysis is completed
{
"crop_id": "crop_123",
"health_score": 0.85,
"analysis_date": "2024-04-15T10:30:00Z",
"recommendations": [
"Increase irrigation",
"Monitor nitrogen levels"
]
}Triggered when a new alert is generated
{
"alert_id": "alert_456",
"severity": "high",
"type": "pest_detection",
"message": "Potential pest infestation detected in Field A"
}Triggered when resource usage exceeds threshold
{
"resource_type": "water",
"current_value": 150,
"threshold": 100,
"field_id": "field_789",
"timestamp": "2024-04-15T14:20:00Z"
}Always verify webhook signatures using your secret key
Only accept webhooks over secure HTTPS connections
Implement proper timeout handling for webhook processing
Handle failed deliveries with exponential backoff
const express = require('express');
const crypto = require('crypto');
const app = express();
app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => {
const signature = req.headers['x-kisan-signature'];
const payload = req.body;
// Verify signature
const isValid = verifySignature(payload, signature, process.env.WEBHOOK_SECRET);
if (!isValid) {
return res.status(400).send('Invalid signature');
}
// Handle the event
const event = JSON.parse(payload);
console.log('Received event:', event.type);
res.json({received: true});
});Start receiving real-time updates for your application.