6.3 KiB
6.3 KiB
🚀 Quick Setup Guide
Your n8n Webhook Configuration
Based on your webhook URL: https://workflows.tech4bizsolutions.com/webhook-test/04e677f5-ec57-4772-bf12-96f2610d4b9c
Step 1: Create .env File
Create a .env file in your project root with these settings:
# ============================================
# n8n Webhook Configuration (YOUR SETUP)
# ============================================
N8N_WEBHOOK_URL=https://workflows.tech4bizsolutions.com
N8N_WEBHOOK_PATH=webhook-test
N8N_WEBHOOK_ID=04e677f5-ec57-4772-bf12-96f2610d4b9c
# ============================================
# Database
# ============================================
DB_HOST=localhost
DB_PORT=3306
DB_NAME=centralized_reporting
DB_USER=root
DB_PASSWORD=your_password
# ============================================
# JWT & Encryption
# ============================================
JWT_SECRET=your_jwt_secret_change_this
JWT_EXPIRES_IN=1h
ENCRYPTION_KEY=changeme
# ============================================
# Server
# ============================================
PORT=3000
NODE_ENV=development
API_PREFIX=/api/v1
# ============================================
# OAuth Credentials
# ============================================
# Zoho
ZOHO_CLIENT_ID=your_zoho_client_id
ZOHO_CLIENT_SECRET=your_zoho_client_secret
ZOHO_REDIRECT_URI=centralizedreportingsystem://oauth/callback
# Salesforce
SALESFORCE_CLIENT_ID=your_salesforce_client_id
SALESFORCE_CLIENT_SECRET=your_salesforce_client_secret
SALESFORCE_REDIRECT_URI=centralizedreportingsystem://oauth/callback
SALESFORCE_INSTANCE_URL=https://login.salesforce.com
# Redis (Optional)
REDIS_HOST=localhost
REDIS_PORT=6379
Step 2: Install Dependencies
npm install
Step 3: Setup Database
# Create database
mysql -u root -p
CREATE DATABASE centralized_reporting;
exit
# Run migrations
node src/db/migrate.js
Step 4: Verify n8n Webhook
Test your n8n webhook is accessible:
curl -X POST https://workflows.tech4bizsolutions.com/webhook-test/04e677f5-ec57-4772-bf12-96f2610d4b9c \
-H "Content-Type: application/json" \
-d '{
"body": {
"provider": "zoho",
"service": "crm",
"module": "leads",
"acces_token": "test_token"
},
"query": {
"per_page": 100,
"page": 1
}
}'
Expected: Should return response from n8n (or error if workflow not active)
Step 5: Start Server
npm start
Server will start at: http://localhost:3000
Step 6: Test Health Check
curl http://localhost:3000/health
Expected Response:
{
"status": "success",
"message": "OK",
"data": {
"db": "up",
"env": "development"
},
"timestamp": "2025-10-09T..."
}
Step 7: Test n8n Integration
7.1 Get Supported Providers
# Login first to get JWT token
curl -X POST http://localhost:3000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "password"
}'
# Save the accessToken from response
TOKEN="your_jwt_token_here"
# Get supported providers
curl -X GET http://localhost:3000/api/v1/n8n/providers \
-H "Authorization: Bearer $TOKEN"
7.2 Authenticate with Provider
# For Zoho (after OAuth flow in frontend)
curl -X GET "http://localhost:3000/api/v1/users/oauth/callback?authorization_code=ABC123&user_uuid=user-id&service_name=zoho"
# For Salesforce
curl -X GET "http://localhost:3000/api/v1/users/oauth/callback?authorization_code=XYZ789&user_uuid=user-id&service_name=salesforce"
7.3 Fetch Data
# Fetch Zoho CRM Leads
curl -X GET "http://localhost:3000/api/v1/n8n/zoho/crm/leads?limit=10" \
-H "Authorization: Bearer $TOKEN"
# Fetch Salesforce Accounts
curl -X GET "http://localhost:3000/api/v1/n8n/salesforce/crm/accounts?limit=10" \
-H "Authorization: Bearer $TOKEN"
📊 How the Webhook URL is Constructed
Configuration
N8N_WEBHOOK_URL=https://workflows.tech4bizsolutions.com
N8N_WEBHOOK_PATH=webhook-test
N8N_WEBHOOK_ID=04e677f5-ec57-4772-bf12-96f2610d4b9c
Code (src/integrations/n8n/client.js)
const url = `${this.baseUrl}/${this.webhookPath}/${this.webhookId}`;
Result
https://workflows.tech4bizsolutions.com/webhook-test/04e677f5-ec57-4772-bf12-96f2610d4b9c
🔍 Verification Checklist
.envfile created with correct values- Database created and migrated
- n8n webhook accessible
- Server starts without errors
- Health check returns success
- Can login and get JWT token
- OAuth callback works
- Can fetch data via n8n
🐛 Common Issues
Issue: "n8n workflow execution failed"
Cause: n8n webhook not accessible or workflow not active
Solution:
- Check n8n is running
- Verify workflow is activated
- Test webhook URL manually:
curl https://workflows.tech4bizsolutions.com/webhook-test/04e677f5-ec57-4772-bf12-96f2610d4b9c
Issue: "Cannot connect to database"
Cause: Database credentials incorrect
Solution:
- Check DB_HOST, DB_PORT, DB_NAME in
.env - Verify MySQL is running
- Test connection:
mysql -h localhost -u root -p
Issue: "JWT token invalid"
Cause: JWT_SECRET mismatch or expired token
Solution:
- Login again to get fresh token
- Verify JWT_SECRET in
.env - Check JWT_EXPIRES_IN setting
📚 Next Steps
-
Configure OAuth Apps
- Set up Zoho OAuth app
- Set up Salesforce Connected App
- Update credentials in
.env
-
Test Full Flow
- Register user
- Authenticate with Zoho/Salesforce
- Fetch data via n8n endpoints
-
Frontend Integration
- Use API endpoints in your frontend
- Implement OAuth flow
- Display fetched data
-
Production Deployment
- Use strong JWT_SECRET
- Use HTTPS
- Enable rate limiting
- Set up monitoring
📖 Documentation
- Full Integration Guide:
docs/N8N_INTEGRATION.md - Environment Variables:
docs/ENVIRONMENT_VARIABLES.md - Salesforce Pagination:
docs/SALESFORCE_PAGINATION.md - Quick Reference:
docs/N8N_QUICK_REFERENCE.md
🆘 Need Help?
Check the logs:
# Server logs
tail -f logs/app.log
# n8n workflow execution logs
# Check in n8n UI: Executions tab
You're all set! Happy coding! 🎉