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

# n8n Integration

> Automate your human-in-the-loop workflows with n8n's powerful visual workflow builder and HITL.sh integration

# n8n Integration

Integrate HITL.sh with n8n to create powerful automated workflows that seamlessly incorporate human decision-making. Perfect for content moderation, approval workflows, and quality assurance processes.

<Note>
  Before configuring n8n, install the HITL.sh mobile app ([App Store](https://apps.apple.com/us/app/hitl-human-in-the-loop/id6752878072) | [Google Play](https://play.google.com/store/apps/details?id=hitl.sh.app)) since it's an integral part of the setup.
</Note>

<Frame>
  <img src="https://mintcdn.com/hitl/jwtPbPwD0u9j8zRm/images/integrations/hitl-pics/n8n-workflow.png?fit=max&auto=format&n=jwtPbPwD0u9j8zRm&q=85&s=1d63b1793d366b55ec6453383196c8cc" alt="n8n workflow with HITL.sh integration" width="2820" height="1816" data-path="images/integrations/hitl-pics/n8n-workflow.png" />
</Frame>

## Why Use n8n with HITL.sh?

<CardGroup cols={2}>
  <Card title="Visual Workflow Builder" icon="diagram-project">
    Design complex automation workflows with an intuitive drag-and-drop interface
  </Card>

  <Card title="300+ Integrations" icon="plug">
    Connect HITL.sh with popular services like Slack, Gmail, databases, and more
  </Card>

  <Card title="Self-Hosted Option" icon="server">
    Deploy on your own infrastructure for complete data control and privacy
  </Card>

  <Card title="Open Source" icon="code">
    Fully transparent codebase you can customize and extend to your needs
  </Card>
</CardGroup>

## Installation Methods

n8n offers two ways to add HITL.sh integration to your workflows:

<Tabs>
  <Tab title="Community Nodes (Recommended)">
    ### Install via Community Nodes

    The easiest way to get started with HITL.sh in n8n:

    <Steps>
      <Step title="Open n8n Settings">
        Navigate to **Settings** → **Community Nodes** in your n8n instance
      </Step>

      <Step title="Install HITL.sh Node">
        Search for `@hitlsh/n8n-nodes-hitl` and click **Install**

        <Frame>
          <img src="https://mintcdn.com/hitl/jwtPbPwD0u9j8zRm/images/integrations/hitl-pics/n8n-community-nodes-installation.png?fit=max&auto=format&n=jwtPbPwD0u9j8zRm&q=85&s=1325cc2a12de6aff2e74f7859e3abe3b" alt="Installing HITL.sh community node in n8n" width="3314" height="1926" data-path="images/integrations/hitl-pics/n8n-community-nodes-installation.png" />
        </Frame>
      </Step>

      <Step title="Restart n8n">
        Restart your n8n instance to load the new nodes
      </Step>

      <Step title="Start Building">
        The HITL.sh nodes will now appear in your node palette
      </Step>
    </Steps>

    <Note>
      Community Nodes are the recommended installation method as they receive automatic updates and simplified configuration.
    </Note>
  </Tab>

  <Tab title="Self-Hosted NPM">
    ### Install via NPM

    For self-hosted n8n instances with custom node installations:

    ```bash theme={null}
    # Navigate to your n8n custom nodes directory
    cd ~/.n8n/nodes

    # Install the HITL.sh node package
    npm install @hitlsh/n8n-nodes-hitl

    # Restart n8n
    n8n restart
    ```

    **Directory Structure:**

    ```
    ~/.n8n/
    ├── nodes/
    │   └── @hitlsh/
    │       └── n8n-nodes-hitl/
    └── config
    ```

    <Warning>
      Self-hosted NPM installation requires manual updates when new versions are released.
    </Warning>
  </Tab>
</Tabs>

## Setting Up Credentials

Configure your HITL.sh API credentials in n8n:

<Steps>
  <Step title="Get Your API Key">
    1. Log in to your HITL.sh dashboard at [my.hitl.sh](https://my.hitl.sh)
    2. Navigate to **Settings** → **API Keys**
    3. Click **Generate New API Key**
    4. Copy your API key (keep it secure!)
  </Step>

  <Step title="Add Credentials in n8n">
    1. In n8n, go to **Credentials** → **New**
    2. Search for "HITL.sh"
    3. Paste your API key

    <Frame>
      <img src="https://mintcdn.com/hitl/jwtPbPwD0u9j8zRm/images/integrations/hitl-pics/n8n-api-credentials-setup.png?fit=max&auto=format&n=jwtPbPwD0u9j8zRm&q=85&s=624790d48b42a86762a201690a5ac09b" alt="Setting up HITL.sh API credentials in n8n" width="3308" height="1908" data-path="images/integrations/hitl-pics/n8n-api-credentials-setup.png" />
    </Frame>
  </Step>

  <Step title="Test Connection">
    Click **Test Credentials** to verify the connection
  </Step>
</Steps>

## Available Response Types

HITL.sh n8n nodes support six different response types for collecting structured feedback from reviewers:

<AccordionGroup>
  <Accordion title="Text Response">
    Free-form text input with character limits:

    ```json theme={null}
    {
      "response_type": "text",
      "response_config": {
        "placeholder": "Enter your feedback...",
        "min_length": 10,
        "max_length": 500,
        "required": true
      }
    }
    ```

    **Response format:** `"response_data": "The content looks good but needs minor edits..."`
  </Accordion>

  <Accordion title="Single Select">
    Choose one option from a predefined list:

    ```json theme={null}
    {
      "response_type": "single_select",
      "response_config": {
        "options": ["Approve", "Reject", "Needs Review"]
      }
    }
    ```

    **Response format:** `"response_data": "approve"`
  </Accordion>

  <Accordion title="Multi Select">
    Choose multiple options from a list:

    ```json theme={null}
    {
      "response_type": "multi_select",
      "response_config": {
        "options": ["Grammar Issues", "Factual Errors", "Tone Problems"],
        "max_selections": 3
      }
    }
    ```

    **Response format:** `"response_data": ["grammar_issues", "tone_problems"]`
  </Accordion>

  <Accordion title="Rating">
    Numeric rating on a custom scale:

    ```json theme={null}
    {
      "response_type": "rating",
      "response_config": {
        "scale_min": 1,
        "scale_max": 10,
        "scale_step": 0.5
      }
    }
    ```

    **Response format:** `"response_data": 7.5`
  </Accordion>

  <Accordion title="Number">
    Numeric input with validation:

    ```json theme={null}
    {
      "response_type": "number",
      "response_config": {
        "min_value": 0,
        "max_value": 1000,
        "decimal_places": 2
      }
    }
    ```

    **Response format:** `"response_data": 299.99`
  </Accordion>

  <Accordion title="Boolean">
    Simple yes/no decisions:

    ```json theme={null}
    {
      "response_type": "boolean",
      "response_config": {
        "true_label": "Approved",
        "false_label": "Rejected"
      }
    }
    ```

    **Response format:** `"response_data": true`
  </Accordion>
</AccordionGroup>

## Configuring the HITL.sh Node

Add the HITL.sh node to your workflow and configure it:

<Frame>
  <img src="https://mintcdn.com/hitl/jwtPbPwD0u9j8zRm/images/integrations/hitl-pics/n8n-node-configuration.png?fit=max&auto=format&n=jwtPbPwD0u9j8zRm&q=85&s=d6b620e48f07b076e3c6759ee53effdc" alt="Configuring HITL.sh node parameters in n8n" width="3252" height="1896" data-path="images/integrations/hitl-pics/n8n-node-configuration.png" />
</Frame>

### Required Parameters

<ParamField body="Loop ID" type="string" required>
  The unique identifier of your HITL loop where reviewers will process the request
</ParamField>

<ParamField body="Request Text" type="string" required>
  The content or question you want reviewers to evaluate
</ParamField>

<ParamField body="Response Type" type="select" required>
  Choose from: text, single\_select, multi\_select, rating, number, boolean
</ParamField>

<ParamField body="Response Config" type="object" required>
  Configuration object specific to your chosen response type
</ParamField>

### Optional Parameters

<ParamField body="Processing Type" type="select" default="time-sensitive">
  `time-sensitive` or `deferred` - determines urgency of the request
</ParamField>

<ParamField body="Priority" type="select" default="medium">
  `low`, `medium`, `high`, or `critical` - affects reviewer notification
</ParamField>

<ParamField body="Timeout Seconds" type="number">
  Time limit before default response is used (60-86400 seconds)
</ParamField>

<ParamField body="Default Response" type="varies">
  Fallback value if request times out (format matches response type)
</ParamField>

<ParamField body="Context" type="object">
  Additional metadata to help reviewers make informed decisions
</ParamField>

## Response Data Structure

When a reviewer completes a request, you'll receive comprehensive response data:

<Frame>
  <img src="https://mintcdn.com/hitl/jwtPbPwD0u9j8zRm/images/integrations/hitl-pics/n8n-response-data-structure.png?fit=max&auto=format&n=jwtPbPwD0u9j8zRm&q=85&s=c809fa42d7fcaf55e41542e915e14f74" alt="Complete response data structure from HITL.sh in n8n" width="1052" height="1628" data-path="images/integrations/hitl-pics/n8n-response-data-structure.png" />
</Frame>

```json theme={null}
{
  "request_id": "65f1234567890abcdef12348",
  "loop_id": "65f1234567890abcdef12345",
  "status": "completed",
  "priority": "high",
  "response_data": "approve",
  "response_by_user": {
    "id": "65f1234567890abcdef12350",
    "name": "John Reviewer",
    "email": "john@example.com"
  },
  "response_time_seconds": 145.5,
  "context": {
    "user_id": "user_123",
    "post_id": "post_456"
  },
  "created_at": "2024-03-15T10:30:00Z",
  "updated_at": "2024-03-15T10:32:25Z"
}
```

## Example Workflow: Customer Refund Approval

Here's a complete workflow that automatically processes refund requests with human oversight:

<Frame>
  <img src="https://mintcdn.com/hitl/jwtPbPwD0u9j8zRm/images/integrations/hitl-pics/customer-refund-approval-workflow.png?fit=max&auto=format&n=jwtPbPwD0u9j8zRm&q=85&s=4da6b4c893daffc0daeed2336f21003a" alt="n8n workflow for customer refund approvals with HITL.sh" width="2812" height="1840" data-path="images/integrations/hitl-pics/customer-refund-approval-workflow.png" />
</Frame>

### Workflow Steps

<Steps>
  <Step title="Trigger: New Refund Request">
    Webhook or form submission triggers when customer requests refund
  </Step>

  <Step title="Check Refund Amount">
    Conditional node routes based on refund amount:

    * Under \$50: Auto-approve
    * $50-$500: Standard review
    * Over \$500: Priority review
  </Step>

  <Step title="HITL.sh Review Node">
    Send to human reviewer with refund details and customer history

    ```json theme={null}
    {
      "loop_id": "refund_approvals",
      "request_text": "Customer requesting ${{ $json.amount }} refund\nReason: {{ $json.reason }}\nCustomer lifetime value: ${{ $json.customer_ltv }}",
      "response_type": "single_select",
      "response_config": {
        "options": ["Approve Full", "Approve Partial", "Deny", "Escalate"]
      },
      "priority": "{{ $json.amount > 500 ? 'high' : 'medium' }}",
      "context": {
        "customer_id": "{{ $json.customer_id }}",
        "order_id": "{{ $json.order_id }}",
        "amount": "{{ $json.amount }}"
      }
    }
    ```
  </Step>

  <Step title="Process Decision">
    Switch node routes based on human decision
  </Step>

  <Step title="Execute Action">
    * **Approved**: Process refund and send confirmation
    * **Denied**: Send explanation email
    * **Escalate**: Notify management team
  </Step>

  <Step title="Update Records">
    Log decision in CRM/database for audit trail
  </Step>
</Steps>

## Best Practices

<CardGroup cols={2}>
  <Card title="Clear Instructions" icon="message">
    Provide reviewers with all context needed to make informed decisions
  </Card>

  <Card title="Appropriate Timeouts" icon="clock">
    Set realistic timeouts based on request urgency and reviewer availability
  </Card>

  <Card title="Safe Defaults" icon="shield">
    Always specify conservative default responses for timeout scenarios
  </Card>

  <Card title="Error Handling" icon="alert-triangle">
    Add error nodes to handle API failures gracefully
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Node Not Appearing">
    **Solution**:

    * Verify installation completed successfully
    * Restart n8n instance
    * Check n8n logs for installation errors
  </Accordion>

  <Accordion title="Authentication Failed">
    **Solution**:

    * Verify API key is correct
    * Check API key has required permissions
    * Ensure API key hasn't expired
  </Accordion>

  <Accordion title="Request Timeout">
    **Solution**:

    * Increase timeout\_seconds parameter
    * Verify loop has active reviewers
    * Check reviewer notification settings
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Zapier Integration" icon="zap" href="/integrations/zapier">
    Learn about our Zapier integration for simpler automation
  </Card>

  <Card title="Make Integration" icon="puzzle" href="/integrations/make">
    Explore Make.com integration with webhook triggers
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/requests/create-request">
    View complete API documentation for custom integrations
  </Card>

  <Card title="Community Support" icon="discord" href="https://discord.gg/jYVrpmnMP9">
    Join our Discord community for help and examples
  </Card>
</CardGroup>
