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

# n8n

> Automate compliance workflows with n8n and DNCScrub APIs

[n8n](https://n8n.io) is a workflow automation platform that connects applications and automates business processes. This guide shows how to integrate DNCScrub APIs into n8n workflows for automated compliance checking.

## Prerequisites

* n8n instance (cloud or self-hosted)
* DNCScrub account with API access
* Your DNCScrub API key (loginId)

## Setting Up Authentication

DNCScrub APIs authenticate via the `loginId` header.

### Create a Credential

1. In n8n, go to **Credentials** → **Add Credential**
2. Select **Header Auth**
3. Configure:
   * **Name**: `DNCScrub API`
   * **Header Name**: `loginId`
   * **Header Value**: Your DNCScrub API key

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/contactcentercompliance/images/n8n-credential-setup.png" alt="n8n Header Auth credential setup" />
</Frame>

## Common Workflow Patterns

### Pre-Dial Compliance Check

Scrub phone numbers before dialing to ensure compliance using Salesforce trigger. n8x can work with multiple tools but this example uses Salesforce.

<Steps>
  <Step title="Add Trigger">
    Use a **Salesforce Trigger** for new leads, a **Webhook** for real-time requests, or a **Schedule Trigger** for batch processing.
  </Step>

  <Step title="Add HTTP Request Node">
    Configure the DNCScrub Scrub API call:

    * **Method**: `GET`
    * **URL**: `https://www.dncscrub.com/app/main/rpc/scrub`
    * **Authentication**: Select your `DNCScrub API` credential
    * **Query Parameters**:
      * `phoneList`: `{{ $json.phone }}`
      * `projId`: YOUR\_PROJECT\_ID (optional)
  </Step>

  <Step title="Add IF Node">
    Check the scrub result:

    * **Condition**: `{{ $json.results[0].Status }}` equals `Ok`
    * **True branch**: Proceed to dial
    * **False branch**: Skip or update CRM
  </Step>

  <Step title="Update CRM">
    Use the **Salesforce Node** to update the lead status based on scrub results.
  </Step>
</Steps>

### Add Contact to Internal DNC

Add to Internal DNC list. when requested by the contact.

```
HTTP Request Configuration:
━━━━━━━━━━━━━━━━━━━━━━━━━━
Method: GET
URL: https://www.dncscrub.com/app/main/rpc/pdnc

Query Parameters:
  phoneList: {{ $json.phone }}
  action: add
  projId: YOUR_PROJECT_ID
```

### Workflow JSON

You can import this workflow directly into n8n:

<Accordion title="Click to view workflow JSON">
  ```json theme={null}
  {
    "nodes": [
      {
        "name": "Salesforce Trigger",
        "type": "n8n-nodes-base.salesforceTrigger",
        "position": [250, 300]
      },
      {
        "name": "DNCScrub",
        "type": "n8n-nodes-base.httpRequest",
        "position": [450, 300],
        "parameters": {
          "method": "GET",
          "url": "https://www.dncscrub.com/app/main/rpc/scrub",
          "authentication": "genericCredentialType",
          "genericAuthType": "httpHeaderAuth",
          "queryParameters": {
            "parameters": [
              {
                "name": "phoneList",
                "value": "={{ $json.Phone }}"
              },
              {
                "name": "projId",
                "value": "YOUR_PROJECT_ID"
              }
            ]
          }
        }
      },
      {
        "name": "Check Result",
        "type": "n8n-nodes-base.if",
        "position": [650, 300],
        "parameters": {
          "conditions": {
            "string": [
              {
                "value1": "={{ $json.results[0].Status }}",
                "value2": "Ok"
              }
            ]
          }
        }
      }
    ]
  }
  ```
</Accordion>

## Error Handling

Add error handling to your workflows:

1. **Set "Continue On Fail"** on HTTP Request nodes to handle API errors gracefully
2. **Add an IF node** after each API call to check for success
3. **Log failures** to a Google Sheet, database, or notification system

## Batch Processing Tips

When processing large lists:

1. **Use the Loop Over Items node** to process records individually
2. **Add a Wait node** (100-200ms) between requests to avoid rate limits
3. **Use POST endpoints** for batches over 10 numbers

## Support

* [DNCScrub API Documentation](/api-reference/introduction)
* [n8n Documentation](https://docs.n8n.io/)
* [Contact Support](mailto:support@dnc.com)
