Skills Development Handling Hex Webhooks and Events

Handling Hex Webhooks and Events

v20260423
hex-webhooks-events
This skill guides developers on implementing event-driven logic for Hex CI/CD workflows. Since Hex does not provide native push webhooks, this method demonstrates how to poll run statuses using callbacks (e.g., TypeScript) to reliably detect task completion or failure. It is essential for integrating Hex pipelines with external services like Slack or custom notification systems.
Get Skill
479 downloads
Overview

Hex Webhooks & Events

Overview

Hex doesn't provide push webhooks. For event-driven integrations, poll run status or build your own notification system around run completions.

Instructions

Run Status Polling with Callback

async function runWithCallback(
  client: HexClient,
  projectId: string,
  params: Record<string, any>,
  onComplete: (result: any) => void,
  onError: (error: Error) => void
) {
  try {
    const { runId } = await client.runProject(projectId, params);
    const poll = async () => {
      const status = await client.getRunStatus(projectId, runId);
      if (status.status === 'COMPLETED') { onComplete(status); return; }
      if (status.status === 'ERRORED' || status.status === 'KILLED') { onError(new Error(status.status)); return; }
      setTimeout(poll, 5000);
    };
    poll();
  } catch (err) { onError(err as Error); }
}

Notify on Completion

runWithCallback(client, 'project-id', { date: '2025-01-01' },
  (result) => {
    // Send Slack notification, email, etc.
    fetch(process.env.SLACK_WEBHOOK_URL!, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ text: `Hex project completed: ${result.runId}` }),
    });
  },
  (error) => console.error('Run failed:', error)
);

Resources

Info
Category Development
Name hex-webhooks-events
Version v20260423
Size 1.91KB
Updated At 2026-04-26
Language