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
- Login to n8n at
https://YOUR_N8N_DOMAIN - Click your profile (top right)
- Go to Settings → API
- Click "Create API Key"
- Give it a name (e.g., "Chatty AI Integration")
- Copy the API key (you won't see it again)
Use API Key in Workflows
Add API key to workflow credentials:
- Open workflow
- Add node that requires authentication
- Click "Create New Credentials"
- Select credential type
- Enter API key
- 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:
- Add "Chatty AI" node
- Select operation (Chat, Completion, etc.)
- Configure prompt
- Execute
Connecting External Apps
1. Connect to Slack
- Add Slack node to workflow
- Click "Create New Credentials"
- Select "OAuth2"
- Click "Connect my account"
- Authorize in Slack
- Credentials saved automatically
2. Connect to Google Sheets
- Add Google Sheets node
- Create credentials
- Select "Service Account" or "OAuth2"
- For Service Account:
- Upload JSON key file
- Or paste service account email and private key
- For OAuth2:
- Click "Connect my account"
- Authorize with Google
3. Connect to Databases
- Add PostgreSQL/MySQL node
- Create credentials
- Enter connection details:
Host: your-db-host
Port: 5432
Database: your_database
User: readonly_user
Password: •••••••• - Test connection
- Save
4. Connect to APIs (Generic)
- Add HTTP Request node
- Create credentials (if needed)
- Select authentication type:
- None - No auth
- Basic Auth - Username/password
- Header Auth - API key in header
- OAuth2 - OAuth flow
- Configure authentication
- Save
App-to-App Connections
Example: Chatty AI → Slack
Trigger → Chatty AI (Generate) → Slack (Send Message)
Setup:
- Add trigger node (Webhook, Schedule, etc.)
- Add Chatty AI node
- Configure prompt
- 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:
- Add Email Trigger node
- Add Chatty AI node
- Prompt:
"Analyze this email: {{$json.body}}"
- Prompt:
- 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:
- Add Webhook node
- Copy webhook URL
- Add Chatty AI node
- Process webhook data
- 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:
- Create new workflow
- Add "Chatty AI" node
- Configure:
- API URL: Pre-configured (
http://chattyai:8080) - API Key: Pre-configured (from environment)
- Model: Select AI model
- Prompt: Your prompt template
- API URL: Pre-configured (
Example Workflow: AI Email Responder
Trigger (Email) → Chatty AI (Generate Response) → Send Email
Steps:
- Add "Email Trigger" node
- Add "Chatty AI" node
- Prompt:
"Generate professional response to: {{$json.body}}"
- Prompt:
- Add "Send Email" node
- To:
{{$json.from}} - Body:
{{$json.response}}
- To:
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
Related Documentation
- Integrations Overview - All integrations
- Core Application Variables - n8n configuration
- MCP Servers - Extend with MCP
- Post-Install Validation - Testing n8n