> ## 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.

# Workflows

> Automate repetitive tasks with triggers and actions

Workflows let you automate tasks in your project using a **Trigger -> Condition -> Action** pattern. When an event occurs, your workflow checks the conditions and runs the actions automatically.

## Creating a workflow

<Steps>
  <Step title="Open workflows">
    Go to the **Workflows** section from your project sidebar or ask the AI assistant to create a workflow.
  </Step>

  <Step title="Choose a trigger">
    Select what starts the workflow.
  </Step>

  <Step title="Add conditions (optional)">
    Filter which trigger events should proceed to the action step.
  </Step>

  <Step title="Define actions">
    Choose what happens when the workflow runs.
  </Step>
</Steps>

## Trigger types

| Trigger             | Description                                                                |
| ------------------- | -------------------------------------------------------------------------- |
| **Webhook**         | Fires when an external service sends a POST request to your workflow URL   |
| **Schedule / Cron** | Fires on a recurring schedule using cron expressions                       |
| **Database**        | Fires when a row is inserted, updated, or deleted in your project database |
| **New visitor**     | Fires when a new unique visitor lands on your site                         |

## Common use cases

* **Auto-deploy** -- deploy your site automatically when changes are pushed to GitHub
* **Notifications** -- send a Slack message or email when a form submission arrives
* **Scheduled tasks** -- generate a weekly analytics report every Monday
* **React to database changes** -- send a welcome email when a new user row is created
* **Marketing automation** -- enroll a new CRM contact in a welcome drip; fire a one-off broadcast on a date

## Marketing email actions

Workflows can fire your saved marketing campaigns and sequences as
actions. Three node types integrate the marketing email platform:

| Node type                   | What it does                                                  | When to use                                                                                       |
| --------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **Send marketing campaign** | Fires an existing `draft` or `scheduled` campaign immediately | One-off broadcast triggered by an event (e.g., contact added → fire welcome blast)                |
| **Add to sequence**         | Enrolls a contact in a saved drip sequence                    | Multi-touch nurture flows (e.g., trial signup → 5-email onboarding over 7 days)                   |
| **Remove from sequence**    | Exits a contact from a sequence                               | Conditions where they should stop receiving (purchased, unsubscribed elsewhere, replied directly) |

<Note>
  These nodes are distinct from the basic **Send Email** action, which
  composes a one-off transactional email inline. Use Send Email for
  notifications (form submissions, password resets); use the marketing
  nodes when you want to fire a campaign you've already designed in
  `/dashboard/marketing/campaigns` or `/dashboard/marketing/sequences`.
</Note>

### Pre-flight requirements

Marketing email nodes require the same gates as the manual Send button
(see the [Setup Checklist](/email-marketing/setup-checklist)):

* `marketing_enabled` on your account
* An active SES tenant
* At least one verified email\_domain that the campaign's from-address
  is on
* A CAN-SPAM physical address on your account

If any gate fails, the node errors at run time and the workflow falls
through to its error branch (or fails the run if no error handler is
attached). Check the customer-facing setup banner on
`/dashboard/marketing/*` to confirm all gates are green before
relying on these nodes in production.

### Idempotency

Add-to-sequence and remove-from-sequence are **idempotent** — re-running
with the same `(sequenceId, contactId)` pair is a safe no-op. Send-campaign
is guarded by status: it only fires for campaigns in `draft` or
`scheduled` status, so accidentally re-firing the same workflow won't
double-send a campaign that's already `sending` or `sent`.

## Run history

Every workflow execution is logged in the **Run History** tab. Each entry shows:

* Trigger event details
* Whether conditions were met
* Action results (success or failure)
* Execution time

## Debugging failed runs

Click a failed run in the history to see the full error trace. Common issues include:

* Invalid webhook payload
* Network timeouts on external API calls
* Missing environment variables

## Dead letter queue

When a workflow fails repeatedly, the event moves to the **Dead Letter Queue**. From there you can:

* **Replay** -- retry the failed event with the same payload
* **Dismiss** -- remove the event from the queue

<Tip>
  Check the dead letter queue periodically to catch recurring failures before they affect your users.
</Tip>

## Workflow credentials

If your workflow calls external APIs, store API keys and tokens in **Workflow Credentials** rather than hardcoding them. Credentials are encrypted and injected at runtime.
