> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hiveku.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflow Recipe: Slack Notifications for Form Submissions

> Get a Slack message every time a visitor submits a form on your site

Turn form submissions into real-time Slack pings so your sales team can respond to leads within minutes — not hours.

<Info>
  Before you start: make sure you have a Slack workspace where you can install an app (or ask an admin), and a form on your Hiveku project that you can wire a webhook to.
</Info>

## The Flow at a Glance

<CardGroup cols={3}>
  <Card title="1. Slack webhook" icon="slack">
    Create an incoming webhook URL in Slack
  </Card>

  <Card title="2. Hiveku workflow" icon="diagram-project">
    Webhook trigger + HTTP action
  </Card>

  <Card title="3. Form wiring" icon="square-poll-vertical">
    Point the form's submit to the trigger URL
  </Card>
</CardGroup>

## Step 1: Create an Incoming Webhook in Slack

<Steps>
  <Step title="Create a new Slack app">
    Go to [api.slack.com/apps](https://api.slack.com/apps) and click **Create New App** > **From scratch**. Give it a name (like `Hiveku Leads`) and pick the workspace you want it installed in.
  </Step>

  <Step title="Enable incoming webhooks">
    In the left sidebar, click **Incoming Webhooks** and toggle **Activate Incoming Webhooks** to **On**.
  </Step>

  <Step title="Add a webhook to your workspace">
    Scroll down and click **Add New Webhook to Workspace**. Pick the target channel (e.g., `#leads`) and click **Allow**.
  </Step>

  <Step title="Copy the webhook URL">
    Slack shows a URL like `https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX`. Copy this — you'll paste it into Hiveku.
  </Step>
</Steps>

<Warning>
  Treat the webhook URL like a password — anyone with it can post into your channel. Don't commit it to git. Store it as a secret in your workflow.
</Warning>

## Step 2: Create the Hiveku Workflow

<Steps>
  <Step title="Open Workflows">
    In your Hiveku project, go to **Workflows** > **New Workflow**. Name it `Form Submission → Slack`.
  </Step>

  <Step title="Add a Webhook trigger">
    Click **Add Trigger** and choose **Webhook**. Hiveku generates a unique webhook URL — copy it, you'll wire your form to it in the next step.
  </Step>

  <Step title="Add an HTTP Request action">
    Click **+ Add Action** > **HTTP Request**. Configure it:

    * **Method:** POST
    * **URL:** paste your Slack webhook URL
    * **Headers:** `Content-Type: application/json`
    * **Body:**

    ```json theme={null}
    {
      "text": "New form submission from {{trigger.name}} ({{trigger.email}}): {{trigger.message}}"
    }
    ```
  </Step>

  <Step title="Save and enable">
    Click **Save**, then toggle **Enabled** in the top right. Until this toggle is on, the workflow won't fire.
  </Step>
</Steps>

<Tip>
  Already have a lead pipeline in mind? From **Workflows > New**, pick the **Form Lead → CRM + Notifications** template — it ships with this Slack step plus a CRM contact action wired up.
</Tip>

## Step 3: Wire Your Form to the Trigger

How you point your form at the trigger URL depends on how your form is built. See the [Workflows overview](/how-tos/workflows) for the full list of options.

<Tabs>
  <Tab title="Native Hiveku form">
    Open the form in the content editor, scroll to **Submission Settings**, and paste the trigger URL into **POST to webhook**.
  </Tab>

  <Tab title="Custom code form">
    In your form's submit handler, POST the form data as JSON to the trigger URL:

    ```typescript theme={null}
    await fetch('https://workflows.hiveku.com/trigger/abc123', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ name, email, message }),
    });
    ```
  </Tab>

  <Tab title="Third-party form">
    Most form providers (Typeform, Tally, Jotform) have a webhook integration. Paste the trigger URL into their webhook settings. Match your field names to what the workflow expects.
  </Tab>
</Tabs>

## Referencing Form Fields

Inside the HTTP Request body, use `{{trigger.fieldName}}` to pull values from the submission. If your form POSTs `{ "name": "Ada", "email": "ada@example.com", "message": "hi" }`, then `{{trigger.name}}` renders as `Ada`.

Fallbacks use the `||` operator:

```json theme={null}
{
  "text": "Lead from {{trigger.name || 'Anonymous'}} — source: {{trigger.source || 'website'}}"
}
```

## Richer Slack Formatting

Plain `text` works fine, but if you want buttons, dividers, or multi-field layouts, use Slack's Block Kit:

```json theme={null}
{
  "blocks": [
    {
      "type": "section",
      "text": { "type": "mrkdwn", "text": "*New lead:* {{trigger.name}}" }
    },
    {
      "type": "section",
      "fields": [
        { "type": "mrkdwn", "text": "*Email:*\n{{trigger.email}}" },
        { "type": "mrkdwn", "text": "*Source:*\n{{trigger.source}}" }
      ]
    }
  ]
}
```

Use Slack's [Block Kit Builder](https://app.slack.com/block-kit-builder) to design visually, then paste the JSON into your HTTP action body.

## Test It

<Steps>
  <Step title="Submit a test form">
    Open your site, fill out the form with test data, and submit.
  </Step>

  <Step title="Check Slack">
    You should see a message in the target channel within a few seconds.
  </Step>

  <Step title="Check the workflow run log">
    Workflows > your workflow > **Runs** tab shows each invocation, the payload received, and the HTTP response from Slack. Useful when nothing shows up.
  </Step>
</Steps>

## Troubleshooting

<AccordionGroup>
  <Accordion title="No Slack message arrives">
    Three common causes: (1) the workflow isn't enabled — toggle it on; (2) the Slack webhook URL is wrong or deleted in Slack — regenerate it in **api.slack.com/apps > your app > Incoming Webhooks**; (3) the trigger never fired — check the workflow's **Runs** tab, and verify your form is POSTing to the correct trigger URL.
  </Accordion>

  <Accordion title="Message formatting is broken">
    Slack returns `invalid_payload` when the JSON is malformed. Quotes and newlines inside form values need escaping. Wrap user-submitted text in the template with safe substitution, or use Block Kit sections which are more forgiving.
  </Accordion>

  <Accordion title="Slow delivery or dropped messages">
    Slack webhooks are rate-limited to roughly 1 message per second per webhook. If you're seeing bursts (e.g., after an ad campaign), add a queueing step or batch submissions into a single message every minute.
  </Accordion>

  <Accordion title="Wrong channel">
    Each Slack incoming webhook is bound to a single channel at creation time. To post to a different channel, create another webhook in Slack (Incoming Webhooks > Add New Webhook to Workspace) and update the URL in your HTTP action.
  </Accordion>

  <Accordion title="Want to route messages by form type?">
    Add a **Conditional** step before the HTTP action that branches on `{{trigger.form_name}}` or similar. One branch posts to `#sales`, another to `#support`.
  </Accordion>
</AccordionGroup>

## What's Next?

<CardGroup cols={2}>
  <Card title="Workflows Basics" icon="diagram-project" href="/how-tos/workflows">
    How triggers, actions, and runs fit together
  </Card>

  <Card title="Leads → CRM Workflow" icon="address-book" href="/how-tos/workflow-leads-to-crm">
    Sync submissions straight into your CRM
  </Card>
</CardGroup>
