xiaohongshu
xiaohongshu
Simulates live updates between Knack backend and Vercel dashboards. Enables near-real-time synchronization of HTI operational data without constant...
Full skill instructions
Simulates live updates between Knack backend and Vercel dashboards. Enables near-real-time synchronization of HTI operational data without constant polling.
Knack doesn't offer native WebSocket support, so we implement:
Purpose: Check for data changes at regular intervals
Parameters:
object_key (string, required): Knack object to monitorinterval_seconds (integer, optional): Polling frequency (default: 60)last_check_timestamp (datetime, optional): Only fetch records modified since this timeon_change (function, optional): Callback when changes detectedExample:
// Poll for new laptops every 60 seconds
poll_updates({
object_key: "object_1",
interval_seconds: 60,
last_check_timestamp: new Date(),
on_change: (new_records) => {
console.log(`${new_records.length} new laptops acquired`);
updateDashboard(new_records);
}
});
Implementation:
async function poll_updates({ object_key, interval_seconds, on_change }) {
let last_check = new Date();
setInterval(async () => {
const changes = await get_records(object_key, {
filters: build_filter({
rules: [{
field: "field_modified_date",
operator: "is after",
value: last_check.toISOString()
}]
})
});
if (changes.records.length > 0) {
on_change(changes.records);
}
last_check = new Date();
}, interval_seconds * 1000);
}
Purpose: Configure Knack to push updates to Vercel endpoint
Parameters:
trigger (string, required): "record_created" | "record_updated" | "record_deleted"object_key (string, required): Which object to monitorurl (string, required): Vercel API route to receive webhooksecret (string, optional): Shared secret for webhook validationKnack Setup (Manual in Knack Builder):
https://your-vercel-app.vercel.app/api/knack-webhookVercel API Route (/api/knack-webhook.js):
export default async function handler(req, res) {
if (req.method !== 'POST') {
return res.status(405).json({ error: 'Method not allowed' });
}
const { object_key, record, action } = req.body;
// Validate webhook (optional)
const signature = req.headers['x-knack-signature'];
if (!validateSignature(signature, req.body)) {
return res.status(401).json({ error: 'Invalid signature' });
}
// Process update
if (action === 'created') {
console.log(`New record in ${object_key}:`, record);
await updateCache(object_key, record);
}
return res.status(200).json({ received: true });
}
Purpose: Identify which records have changed since last sync
Example:
const changed = await detect_changes({
object_key: "object_1",
since: last_sync_timestamp,
fields_to_watch: ["field_status", "field_county"]
});
Logic:
// Real-time status updates for ops dashboard
poll_updates({
object_key: "object_1",
interval_seconds: 30, // Check every 30 seconds
on_change: (devices) => {
const ready = devices.filter(d => d.status === "Ready for Donation");
if (ready.length > 0) {
notifyTeam(`${ready.length} new devices ready for distribution`);
}
}
});
// Monitor new sign-ups for digital literacy classes
poll_updates({
object_key: "object_training",
interval_seconds: 120, // Every 2 minutes
on_change: (sessions) => {
updateCapacityWidget(sessions);
}
});
// Webhook fires when new donation record created
register_webhook({
trigger: "record_created",
object_key: "object_donations",
url: "https://hubdash.vercel.app/api/donation-alert",
on_receive: async (donation) => {
await sendSlackNotification({
channel: "#donations",
text: `New donation: ${donation.org_name} - ${donation.laptop_count} laptops`
});
}
});
// When device status changes to "Ready", trigger distribution workflow
register_webhook({
trigger: "record_updated",
object_key: "object_1",
url: "https://hubdash.vercel.app/api/device-ready",
filter_condition: (record) => record.status === "Ready for Donation"
});
// Adaptive polling: slower when idle, faster when active
let poll_interval = 60; // Start at 60 seconds
poll_updates({
object_key: "object_1",
interval_seconds: poll_interval,
on_change: (records) => {
if (records.length > 10) {
poll_interval = 15; // Speed up if lots of activity
} else {
poll_interval = Math.min(poll_interval + 15, 180); // Slow down if quiet
}
}
});
// Only fetch modified fields, not entire records
const changes = await poll_updates({
object_key: "object_1",
fields: ["field_status", "field_county"], // Only these fields
since: last_check
});
Knack Limit: 10 requests/second
Polling Strategy:
Best Practice: Use webhooks for critical updates, polling for less urgent data
async function robust_poll(object_key) {
try {
const updates = await poll_updates({ object_key });
return updates;
} catch (error) {
if (error.status === 429) {
// Rate limit - increase interval
console.warn("Rate limit hit, slowing polling...");
await sleep(5000);
} else if (error.status >= 500) {
// Server error - retry with backoff
await exponentialBackoff(poll_updates, { object_key });
} else {
throw error;
}
}
}
/api
/knack-webhook.js # Receives Knack webhooks
/poll-updates.js # Serverless function for polling
/cache-invalidate.js # Clear cache on updates
KNACK_WEBHOOK_SECRET=your_secret_here
KNACK_APP_ID=your_app_id
KNACK_API_KEY=your_api_key
# Simulate Knack webhook locally
curl -X POST http://localhost:3000/api/knack-webhook \
-H "Content-Type: application/json" \
-d '{
"object_key": "object_1",
"action": "created",
"record": { "id": "test123", "status": "Ready" }
}'
// Test polling logic without hitting Knack API
const mock_changes = [
{ id: "1", status: "Ready" },
{ id: "2", status: "Converted" }
];
on_change(mock_changes);
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience