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

# n8n Integration

> Connect Legnext AI API with n8n to build automated workflows

## Overview

n8n is a powerful workflow automation tool that allows you to connect various services and APIs. By integrating Legnext AI API with n8n, you can:

* **Automate Image Generation** - Trigger image creation based on events from other services
* **Build Complex Workflows** - Chain multiple operations together
* **Process Data at Scale** - Handle bulk image generation tasks
* **No Coding Required** - Use visual workflow editor

## Key Features

* **Visual Workflow Builder**: Create complex automations with a drag-and-drop interface.
* **Advanced Logic**: Use if-statements, loops, and merges to build sophisticated pipelines.
* **Self-Hosted Option**: Run n8n on your own infrastructure for complete data control.
* **Community Nodes**: Access a wide range of community-built nodes and workflows.

## Video Tutorial

Watch this tutorial to learn how to set up Legnext with n8n:

<iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/froFi98e79o" title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

## Getting Started

### Prerequisites

* An n8n instance (self-hosted or cloud)
* A Legnext API key ([Get one here](https://legnext.ai))
* Basic understanding of workflow automation

### Installation

1. **Download the Preset Workflow**

   [Download Preset Workflow](https://raw.githubusercontent.com/leggiemint/legnext-resources/refs/heads/main/example_workflow.json)

2. **Import into n8n**
   * Open your n8n instance
   * Go to Workflows
   * Click "Import from File"
   * Select the downloaded JSON file

3. **Configure API Credentials**
   * Add your Legnext API key to the HTTP Request nodes
   * Test the connection

## Use Cases

### Automated Social Media Content

Create a workflow that generates images based on trending topics and posts them to social media platforms.

### E-commerce Product Images

Generate product images automatically when new items are added to your inventory system.

### Content Pipeline

Build a content creation pipeline that generates images for blog posts, newsletters, or marketing materials.

### Scheduled Image Generation

Set up scheduled workflows to generate images at specific times or intervals.

## Best Practices

* **Error Handling** - Add error handling nodes to manage API failures gracefully
* **Rate Limiting** - Be mindful of API rate limits when processing large batches
* **Webhook Configuration** - Use webhooks for async operations to avoid timeout issues
* **Data Validation** - Validate input data before sending to the API

## Troubleshooting

### Common Issues

**Connection Timeout**

* Use webhook callbacks for long-running operations
* Increase timeout settings in n8n HTTP Request node

**API Key Errors**

* Verify your API key is correctly configured
* Check that the key has proper permissions

**Invalid Parameters**

* Review the API documentation for correct parameter formats
* Validate your input data before sending requests

## Need Help?

If you need assistance with n8n integration, reach out to our support team at [support@legnext.ai](mailto:support@legnext.ai)
