Guides

Slack Integration

Send webhook events to Slack channels

Nahook can deliver events directly to Slack channels using Slack's Incoming Webhooks. This is useful for alerting, notifications, and monitoring.

Setup

1. Create a Slack Incoming Webhook

  1. Go to api.slack.com/apps and click Create New App
  2. Choose From scratch, name your app, and select your workspace
  3. Under Features, click Incoming Webhooks and toggle it on
  4. Click Add New Webhook to Workspace
  5. Select the channel where you want to receive events
  6. Click Allow and copy the webhook URL

The URL looks like: https://hooks.slack.com/services/T.../B.../xxx

2. Create a Slack Endpoint in Nahook

In the dashboard, go to EndpointsCreate Endpoint, select the target environment, and choose Slack as the type. Paste your Slack webhook URL.

Or use the API:

curl -X POST https://api.nahook.com/api/workspaces/ws_YOUR_ID/endpoints \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "slack",
    "config": {
      "webhookUrl": "https://hooks.slack.com/services/T.../B.../xxx"
    },
    "description": "#alerts channel"
  }'
const response = await fetch(
  "https://api.nahook.com/api/workspaces/ws_YOUR_ID/endpoints",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_SESSION_TOKEN",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      type: "slack",
      config: {
        webhookUrl: "https://hooks.slack.com/services/T.../B.../xxx",
      },
      description: "#alerts channel",
    }),
  },
);

3. Send a Test Event

Click Test on the endpoint detail page, or use the API:

curl -X POST https://api.nahook.com/api/workspaces/ws_YOUR_ID/endpoints/ep_YOUR_ID/test \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"

You should see a message in your Slack channel: "Nahook test — your Slack integration is working!"

How Slack Delivery Works

Slack endpoints behave differently from standard webhooks:

FeatureWebhookSlack
SigningHMAC-SHA256 headersNone (Slack handles auth)
Success criteriaHTTP 200-299HTTP 200 only
Payload formatYour JSON payloadSlack message format
AuthOptional HTTP Basic AuthWebhook URL is the secret

Message Format

When you send events to a Slack endpoint, the payload is POSTed directly to Slack. To display formatted messages, use Slack's message format:

{
  "payload": {
    "text": "New order received: $99.99 from [email protected]"
  }
}

For rich formatting with blocks:

{
  "payload": {
    "blocks": [
      {
        "type": "header",
        "text": { "type": "plain_text", "text": "New Order Received" }
      },
      {
        "type": "section",
        "fields": [
          { "type": "mrkdwn", "text": "*Amount:*\n$99.99" },
          { "type": "mrkdwn", "text": "*Customer:*\n[email protected]" }
        ]
      }
    ]
  }
}

The text field is recommended even when using blocks — it serves as a fallback for notifications and accessibility.

Security

The Slack webhook URL contains an authentication token. Treat it as a secret:

  • Don't commit it to version control
  • Nahook stores it securely in the endpoint configuration
  • Rotate it by creating a new Incoming Webhook in Slack and updating the endpoint