Skip to main content

n8n Workflow Automation

n8n is a workflow automation platform integrated with Chatty AI for creating custom automations and workflows.

Overview

n8n comes pre-configured with Chatty AI and is ready to use immediately after deployment.

Key Features:

  • Visual workflow builder
  • 400+ pre-built integrations
  • Custom code execution (JavaScript/Python)
  • Webhooks and triggers
  • Chatty AI node for AI-powered workflows

Access n8n

Web Interface

# Access n8n UI
https://YOUR_N8N_DOMAIN

# Example
https://n8n.example.com

Authentication

n8n uses Chatty AI authentication:

  • Login with your Chatty AI credentials
  • Same user management as Chatty AI
  • No separate n8n account needed

Configuration

Environment Variables

n8n is auto-configured via these variables:

# n8n Domain
N8N_DOMAIN=n8n.example.com
N8N_URL=https://n8n.example.com

# n8n Configuration
N8N_ENABLED=true
N8N_API_KEY=${CHATTYAI_API_KEY}
N8N_USER_MANAGEMENT_DISABLED=true
N8N_SECURE_COOKIE=true

See Core Application Variables for all options.


Setting Up n8n API Key

Generate API Key in n8n

  1. Login to n8n at https://YOUR_N8N_DOMAIN
  2. Click your profile (top right)
  3. Go to SettingsAPI
  4. Click "Create API Key"
  5. Give it a name (e.g., "Chatty AI Integration")
  6. Copy the API key (you won't see it again)

Use API Key in Workflows

Add API key to workflow credentials:

  1. Open workflow
  2. Add node that requires authentication
  3. Click "Create New Credentials"
  4. Select credential type
  5. Enter API key
  6. Save credentials

Connecting Apps in n8n

Connecting Chatty AI to n8n

Pre-configured connection - no setup needed:

  • API URL: http://chattyai:8080
  • API Key: Auto-configured from environment
  • Model: Select from available models

To use in workflow:

  1. Add "Chatty AI" node
  2. Select operation (Chat, Completion, etc.)
  3. Configure prompt
  4. Execute

Connecting External Apps

1. Connect to Slack

  1. Add Slack node to workflow
  2. Click "Create New Credentials"
  3. Select "OAuth2"
  4. Click "Connect my account"
  5. Authorize in Slack
  6. Credentials saved automatically

2. Connect to Google Sheets

  1. Add Google Sheets node
  2. Create credentials
  3. Select "Service Account" or "OAuth2"
  4. For Service Account:
    • Upload JSON key file
    • Or paste service account email and private key
  5. For OAuth2:
    • Click "Connect my account"
    • Authorize with Google

3. Connect to Databases

  1. Add PostgreSQL/MySQL node
  2. Create credentials
  3. Enter connection details:
    Host: your-db-host
    Port: 5432
    Database: your_database
    User: readonly_user
    Password: ••••••••
  4. Test connection
  5. Save

4. Connect to APIs (Generic)

  1. Add HTTP Request node
  2. Create credentials (if needed)
  3. Select authentication type:
    • None - No auth
    • Basic Auth - Username/password
    • Header Auth - API key in header
    • OAuth2 - OAuth flow
  4. Configure authentication
  5. Save

App-to-App Connections

Example: Chatty AI → Slack

Trigger → Chatty AI (Generate) → Slack (Send Message)

Setup:

  1. Add trigger node (Webhook, Schedule, etc.)
  2. Add Chatty AI node
    • Configure prompt
  3. Add Slack node
    • Select "Send Message"
    • Channel: Select channel
    • Message: Use output from Chatty AI: {{$json.response}}

Example: Email → Chatty AI → Google Sheets

Email Trigger → Chatty AI (Analyze) → Google Sheets (Append)

Setup:

  1. Add Email Trigger node
  2. Add Chatty AI node
    • Prompt: "Analyze this email: {{$json.body}}"
  3. Add Google Sheets node
    • Operation: Append
    • Sheet: Select sheet
    • Data: Map fields from Chatty AI output

Example: Webhook → Chatty AI → Database

Webhook → Chatty AI (Process) → PostgreSQL (Insert)

Setup:

  1. Add Webhook node
    • Copy webhook URL
  2. Add Chatty AI node
    • Process webhook data
  3. Add PostgreSQL node
    • Operation: Insert
    • Table: Select table
    • Columns: Map from Chatty AI output

Using Chatty AI in n8n Workflows

Chatty AI Node

n8n includes a pre-configured Chatty AI node:

  1. Create new workflow
  2. Add "Chatty AI" node
  3. Configure:
    • API URL: Pre-configured (http://chattyai:8080)
    • API Key: Pre-configured (from environment)
    • Model: Select AI model
    • Prompt: Your prompt template

Example Workflow: AI Email Responder

Trigger (Email) → Chatty AI (Generate Response) → Send Email

Steps:

  1. Add "Email Trigger" node
  2. Add "Chatty AI" node
    • Prompt: "Generate professional response to: {{$json.body}}"
  3. Add "Send Email" node
    • To: {{$json.from}}
    • Body: {{$json.response}}

Common Workflows

1. Document Processing

Webhook → Download File → Chatty AI (Analyze) → Save to Database

2. Slack Bot

Slack Trigger → Chatty AI (Respond) → Send Slack Message

3. Data Enrichment

Schedule → Fetch Data → Chatty AI (Enrich) → Update CRM

4. Content Generation

Trigger → Chatty AI (Generate) → Format → Post to CMS

API Access

n8n API

Access n8n programmatically:

# Get workflows
curl https://n8n.example.com/api/v1/workflows \
-H "X-N8N-API-KEY: YOUR_API_KEY"

# Execute workflow
curl -X POST https://n8n.example.com/api/v1/workflows/123/execute \
-H "X-N8N-API-KEY: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"data": "value"}'

Webhooks

Create webhook-triggered workflows:

# Webhook URL format
https://n8n.example.com/webhook/your-webhook-id

# Trigger workflow
curl -X POST https://n8n.example.com/webhook/your-webhook-id \
-H "Content-Type: application/json" \
-d '{"message": "Hello"}'

Troubleshooting

Cannot Access n8n UI

# Check n8n is running
docker compose ps n8n

# Check logs
docker compose logs n8n

# Verify domain configuration
grep N8N_DOMAIN .env

# Test connectivity
curl -k https://n8n.example.com

Chatty AI Node Not Working

# Verify API key
docker compose exec n8n env | grep N8N_CHATTYAI_API_KEY

# Test Chatty AI API
curl http://chattyai:8080/api/health

# Check network connectivity
docker exec n8n ping chattyai

Workflow Execution Fails

# Check workflow logs in n8n UI
# Executions → Select execution → View logs

# Check n8n container logs
docker compose logs n8n --tail=100

# Verify credentials configured correctly

Best Practices

1. Error Handling

Always add error handling to workflows:

  • Use "Error Trigger" node
  • Add "If" nodes for conditional logic
  • Set up notifications for failures

2. Testing

Test workflows before production:

  • Use test data
  • Verify all nodes execute correctly
  • Check error scenarios

3. Monitoring

Monitor workflow executions:

  • Review execution history
  • Set up failure notifications
  • Track performance metrics

4. Security

Secure your workflows:

  • Use environment variables for secrets
  • Limit webhook access
  • Validate input data
  • Use HTTPS for all connections