Skip to content

gfirik/smart-home-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Smart Home Setup Assistant - n8n AI Sales Bot

An automated AI-powered sales assistant for smart home installation services, built with n8n, Telegram, and GPT. This bot handles customer inquiries, guides them through the sales funnel, and schedules appointments.

Features

  • Telegram bot integration for customer communication
  • AI-powered sales conversations using GPT-4
  • Automated lead qualification and data collection
  • Calendar integration for appointment scheduling
  • PostgreSQL database for conversation memory and persistent storage
  • Google Sheets integration for lead management
  • Google Calendar integration for installation appointments
  • Smart home-specific sales script and objection handling

Prerequisites

  • Docker and Docker Compose installed
  • ngrok account (for webhook URL)
  • Telegram Bot Token
  • OpenAI API key (GPT-4 access)
  • Google OAuth credentials (for Sheets/Calendar integration)
  • Basic understanding of n8n workflows

Project Structure

.
β”œβ”€β”€ docker-compose.yml                  # Docker services configuration
β”œβ”€β”€ .env                                # Environment variables (DO NOT COMMIT)
β”œβ”€β”€ .gitignore                          # Git ignore file
β”œβ”€β”€ smart_home_assistant.json           # n8n workflow export (smart home setup)
β”œβ”€β”€ start.sh                            # One-command script to start everything
β”œβ”€β”€ stop.sh                             # One-command script to stop everything
└── README.md                           # This file

Credential Setup Guide

Before starting the containers, you need to obtain several API keys and credentials. Follow these steps:

1. Get ngrok URL (Public Webhook)

n8n needs a public URL for webhooks (Telegram, OAuth callbacks).

# Install ngrok (if not installed)
# Download from https://ngrok.com/download

# Start ngrok tunnel
ngrok http 5678

Copy the HTTPS URL (e.g., https://abc123.ngrok-free.app) - you'll need this for .env

Note: Free ngrok URLs change every time you restart. For production, use:

  • ngrok paid plan (persistent domain)
  • Your own domain with reverse proxy
  • Cloud hosting (AWS, DigitalOcean, etc.)

2. Create Telegram Bot

  1. Open Telegram and search for @BotFather
  2. Send /newbot
  3. Choose a name: Smart Home Assistant
  4. Choose a username: your_smarthome_bot (must end with 'bot')
  5. Copy the Bot Token (looks like: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
  6. Save this token - you'll add it in n8n later

3. Get OpenAI API Key

  1. Go to OpenAI API Keys
  2. Sign in or create an account
  3. Click "Create new secret key"
  4. Name it: n8n-smart-home-bot
  5. Copy the key (starts with sk-...)
  6. Important: Add credits to your OpenAI account (GPT-4 requires paid account)
  7. Save this key - you'll add it in n8n later

Pricing: GPT-4 costs vary. Check OpenAI Pricing

4. Setup Google Cloud Project (for Sheets & Calendar)

4.1 Create Google Cloud Project

  1. Go to Google Cloud Console
  2. Click "Create Project"
  3. Name: n8n-smart-home-bot
  4. Click "Create"

4.2 Enable APIs

  1. In your project, go to "APIs & Services" > "Library"
  2. Search and enable:
    • Google Sheets API
    • Google Calendar API

4.3 Create OAuth Credentials

  1. Go to "APIs & Services" > "Credentials"
  2. Click "Configure Consent Screen":
    • User Type: External
    • App name: Smart Home Bot
    • User support email: your email
    • Developer contact: your email
    • Click "Save and Continue"
  3. Scopes: Click "Add or Remove Scopes", search and add:
    • Google Sheets API β†’ .../auth/spreadsheets
    • Google Calendar API β†’ .../auth/calendar
    • Click "Update" then "Save and Continue"
  4. Test users: Add your Gmail address, click "Save and Continue"
  5. Go to "Credentials" tab
  6. Click "Create Credentials" > "OAuth 2.0 Client ID"
  7. Application type: Web application
  8. Name: n8n-oauth
  9. Authorized redirect URIs: Add your ngrok URL + callback path:
    https://YOUR-NGROK-URL.ngrok-free.app/rest/oauth2-credential/callback
    
    Example: https://abc123.ngrok-free.app/rest/oauth2-credential/callback
  10. Click "Create"
  11. Save the Client ID and Client Secret - you'll need these in n8n

5. Create Google Sheets

Create two Google Sheets for your bot:

Sheet 1: Product/Service Catalog (Price List)

  1. Go to Google Sheets
  2. Create new sheet, name it: Smart Home Products
  3. Add headers and sample data:
    | Product          | Price  | Description                           |
    |------------------|--------|---------------------------------------|
    | Basic Package    | $999   | Smart lights + voice control          |
    | Security Package | $1,499 | Cameras + smart locks + sensors       |
    | Full Home        | $3,999 | Complete automation for entire home   |
    
  4. Share the sheet with your Google account email
  5. Copy the Sheet ID from URL: https://docs.google.com/spreadsheets/d/SHEET_ID_HERE/edit

Sheet 2: Client Database (Leads)

  1. Create another sheet, name it: Smart Home Leads
  2. Add headers:
    | name | phone | email | description |
    
  3. Copy the Sheet ID from URL

6. Setup Google Calendar

  1. Go to Google Calendar
  2. Create a new calendar:
    • Click "+" next to "Other calendars"
    • "Create new calendar"
    • Name: Smart Home Installations
    • Click "Create calendar"
  3. Note your calendar email (usually your Gmail address)

Quick Start

Automated One-Command Setup (Recommended)

We've created automated scripts to simplify startup and shutdown:

Start Everything

./start.sh

This single command will:

  1. βœ… Start Docker containers (n8n + PostgreSQL)
  2. βœ… Launch ngrok tunnel for port 5678
  3. βœ… Wait for ngrok to initialize
  4. βœ… Extract the public ngrok URL
  5. βœ… Automatically update .env file with the new ngrok URL
  6. βœ… Update OAuth redirect URI in .env
  7. βœ… Display webhook registration instructions

Output example:

βœ… Project started successfully!
πŸ“ ngrok URL: https://f23bcce90eba.ngrok-free.app (updated in .env)

πŸ”— Access n8n at:
   Local:  http://localhost:5678
   Public: https://f23bcce90eba.ngrok-free.app

⚠️  IMPORTANT FOR TELEGRAM BOT:
If you've restarted ngrok, you MUST register the webhook again:

curl -X POST "https://api.telegram.org/botYOUR_BOT_TOKEN/setWebhook" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://f23bcce90eba.ngrok-free.app/webhook/telegram"}'

⚠️ Important Note - Free ngrok URLs are temporary:

  • Free ngrok URLs change every time you restart
  • Each time you run ./start.sh, you get a NEW URL
  • You must register the new webhook with Telegram after each restart
  • The script displays the webhook registration command for you to copy-paste

Stop Everything

./stop.sh

This command will:

  1. βœ… Pause all Docker containers (data is preserved)
  2. βœ… Stop ngrok tunnel
  3. βœ… Show instructions for restart

Note: Containers are stopped but not removed. All data (n8n workflows, PostgreSQL database) is preserved. Simply run ./start.sh again to resume.

Workflow Auto-Import

The workflow is automatically imported on first container start using n8n's CLI!

How it works:

  1. Run ./start.sh β†’ containers start
  2. After n8n is ready, the workflow is imported via n8n CLI
  3. If workflow already exists (from previous session), it's skipped
  4. Open http://localhost:5678 β†’ workflow is there with all your data intact!

Key features:

  • βœ… Automatic on first start (no manual import needed)
  • βœ… Idempotent (safe to restart, won't duplicate or overwrite)
  • βœ… Preserves all previous data (credentials, executions, history)
  • βœ… Can force reimport with ./start.sh --reimport (overwrites existing)
  • βœ… Data persists across stop/start cycles

Workflow restart behavior:

Command Container Data Workflow
./stop.sh Stopped βœ… Preserved βœ… Preserved
./start.sh (after stop) Restarted βœ… Intact βœ… Still there
docker compose down Removed ❌ Deleted ❌ Deleted

| ./stop.sh | Stopped | βœ… Preserved | βœ… Preserved | | ./start.sh (after stop) | Restarted | βœ… Intact | βœ… Still there | | docker compose down | Removed | ❌ Deleted | ❌ Deleted |

Manual reimport (if needed):

# Force reimport workflow on next start
./start.sh --reimport

# Or reimport via n8n UI:
# 1. Click Menu (☰) β†’ Workflows β†’ Import
# 2. Select smart_home_assistant.json
# 3. Click Import

Output example:

βœ… Project stopped! All containers and ngrok tunnel shut down.

Prerequisites for Automated Scripts

Before using start.sh, ensure:

  • βœ… Docker and Docker Compose are installed
  • βœ… ngrok is installed and accessible in your PATH

Manual Setup (If Not Using Automated Scripts)

If you prefer manual control, use Docker Compose directly:

1. Configure Environment Variables

Edit the .env file with your credentials:

# n8n Authentication
N8N_USER=admin
N8N_PASS=adminpass

# Public URL (ngrok or your domain)
NGROK_URL=https://your-ngrok-url.ngrok-free.app

# PostgreSQL Database
PG_USER=pguser
PG_PASS=pgpass
PG_DB=memorydb

# OAuth Redirect (for Google integrations)
oauth_redirect_uri=https://your-ngrok-url.ngrok-free.app/rest/oauth2-credential/callback

2. Start the Containers

# Start all services
docker compose up -d

# View logs
# View logs
docker-compose logs -f

# Check running containers
docker-compose ps

3. Access n8n

Open your browser and navigate to:

  • Local Access: http://localhost:5678 (Port: 5678)
  • Public Access: Your ngrok URL (e.g., https://f23bcce90eba.ngrok-free.app)

Login with credentials from .env:

  • Username: admin (or your N8N_USER)
  • Password: adminpass (or your N8N_PASS)

4. Import the Workflow

  1. In n8n, click on "Workflows" in the left sidebar
  2. Click "Add workflow" > "Import from file"
  3. Select smart_home_assistant.json
  4. The workflow will open with "smart home setup assistant" name

5. Configure Credentials in n8n

You need to set up 5 different credentials in the workflow. Click on each node that shows a credential error (red exclamation mark).

5.1 Telegram Bot Credentials
  1. Click on "Telegram Trigger" node
  2. Under "Credential to connect with", click "Create New"
  3. Name: Smart Home Bot
  4. Access Token: Paste your Telegram Bot Token from BotFather
  5. Click "Save"
  6. Do the same for "Send a text message" node (or select the same credential)
5.2 OpenAI Credentials
  1. Click on "OpenAI Chat Model" node
  2. Under "Credential to connect with", click "Create New"
  3. Name: OpenAI GPT-4
  4. API Key: Paste your OpenAI API key (starts with sk-...)
  5. Click "Save"
5.3 PostgreSQL Credentials
  1. Click on "Postgres Chat Memory" node
  2. Under "Credential to connect with", click "Create New"
  3. Fill in the database connection details:
    • Host: postgres_memory (this is the Docker service name)
    • Database: memorydb (or your PG_DB value)
    • User: pguser (or your PG_USER value)
    • Password: pgpass (or your PG_PASS value)
    • Port: 5432 (internal Docker port, NOT 5444)
    • SSL: disable (for local development)
  4. Name: Postgres Memory DB
  5. Click "Save"
5.4 Google Sheets OAuth Credentials
  1. Click on "Get row(s) in sheet in Google Sheets" node
  2. Under "Credential to connect with", click "Create New"
  3. You'll see OAuth setup:
    • OAuth Redirect URL: Copy this URL (should match what you set in Google Cloud Console)
    • Client ID: Paste from Google Cloud Console
    • Client Secret: Paste from Google Cloud Console
  4. Name: Google Sheets Account
  5. Click "Sign in with Google"
  6. Authorize the app (you may see "unverified app" warning - click "Advanced" > "Go to app")
  7. Grant permissions for Google Sheets and Calendar
  8. Click "Save"
  9. Repeat for "Append row in sheet in Google Sheets" node (select the same credential)
5.5 Google Calendar OAuth Credentials
  1. Click on "Get an event in Google Calendar" node
  2. Under "Credential to connect with", click "Create New" OR select the same Google OAuth credential from Sheets
  3. If creating new:
    • Client ID: Same as Google Sheets
    • Client Secret: Same as Google Sheets
    • Click "Sign in with Google"
    • Authorize
  4. Name: Google Calendar Account
  5. Click "Save"
  6. Repeat for "Create an event in Google Calendar" node (select the same credential)

Note: Google Sheets and Google Calendar can use the SAME OAuth credential if you enabled both APIs in the same Google Cloud project.

5.6 Configure Google Sheets Document IDs
  1. Click on "Get row(s) in sheet in Google Sheets" node

  2. Click on "Document" dropdown

  3. Click "From list" (it should fetch your Google Sheets)

  4. Select "Smart Home Products" (your price list sheet)

  5. Select the sheet tab (usually "Sheet1")

  6. Click "Save"

  7. Click on "Append row in sheet in Google Sheets" node

  8. Select "Smart Home Leads" (your client database)

  9. Click "Save"

5.7 Configure Google Calendar
  1. Click on "Get an event in Google Calendar" node

  2. Under "Calendar", select your email or calendar name

  3. Click "Save"

  4. Click on "Create an event in Google Calendar" node

  5. Under "Calendar", select the same calendar

  6. Click "Save"

6. Activate the Workflow

  1. Click "Save" button (top right)
  2. Toggle the workflow to "Active" (switch in top right turns green)
  3. The Telegram webhook should now be registered

7. Test Your Bot

  1. Open Telegram
  2. Search for your bot username
  3. Send /start or any message
  4. The bot should respond with the smart home sales pitch!

If bot doesn't respond:

  • Check n8n "Executions" tab for errors
  • Verify ngrok is still running
  • Check all credentials are properly configured
  • Look at Docker logs: docker-compose logs -f n8n

Managing the Containers

Using Automated Scripts

# Start everything with one command
./start.sh

# Stop everything with one command
./stop.sh

Manual Docker Commands

# Stop services (containers keep running)
docker compose stop

# Restart services
docker compose restart

# Stop and remove containers
docker compose down

# Stop and remove everything (including volumes)
docker compose down -v

# View logs
docker-compose logs -f

# View logs for specific service
docker-compose logs -f n8n
docker-compose logs -f postgres_memory

# Rebuild containers
docker compose up -d --build

6. Activate the Workflow

  1. Click "Save" button (top right)
  2. Toggle the workflow to "Active" (switch in top right turns green)
  3. The Telegram webhook should now be registered

7. Test Your Bot

  1. Open Telegram
  2. Search for your bot username
  3. Send /start or any message
  4. The bot should respond with the smart home sales pitch!

If bot doesn't respond:

  • Check n8n "Executions" tab for errors
  • Verify ngrok is still running
  • Check all credentials are properly configured
  • Look at Docker logs: docker-compose logs -f n8n

Managing the Containers

Stop Services

docker-compose stop

Restart Services

docker-compose restart

Stop and Remove Containers

docker-compose down

Stop and Remove Everything (including volumes)

docker-compose down -v

View Logs

# All services
docker-compose logs -f

# Specific service
docker-compose logs -f n8n
docker-compose logs -f postgres_memory

Rebuild Containers

docker-compose up -d --build

Database Access

PostgreSQL is accessible on port 5444:

# Connect to PostgreSQL
# First, get your container name:
CONTAINER=$(docker ps --filter "ancestor=postgres:15" --format "{{.Names}}")
docker exec -it $CONTAINER psql -U pguser -d memorydb

# Or use external client (from your machine)
psql -h localhost -p 5444 -U pguser -d memorydb

Backup and Restore

Backup n8n Data

# Backup workflow data
docker-compose exec n8n n8n export:workflow --all --output=/home/node/.n8n/workflows_backup.json

# Copy from container (get container name dynamically)
CONTAINER=$(docker ps --filter "ancestor=n8nio/n8n:latest" --format "{{.Names}}")
mkdir -p backup
docker cp $CONTAINER:/home/node/.n8n/workflows_backup.json ./backup/

Backup Database

docker-compose exec postgres_memory pg_dump -U pguser memorydb > backup_$(date +%Y%m%d).sql

Restore Database

cat backup.sql | docker-compose exec -T postgres_memory psql -U pguser -d memorydb

Troubleshooting

πŸ”΄ Telegram Bot Not Responding (Most Common Issue)

This happens when the Telegram webhook is not properly registered with Telegram servers. Follow these steps:

Step 1: Verify ngrok is Running

# Check if ngrok process is running
pgrep -a ngrok

# Should show: ngrok http 5678

If ngrok is NOT running, restart with:

./stop.sh && ./start.sh

Step 2: Verify ngrok URL is Correct

# Check your current .env file
cat .env | grep NGROK_URL

# Should show something like: NGROK_URL=https://abc123.ngrok-free.app

Important: ngrok URLs change every time you restart ngrok. If you restarted ngrok, the old URL is dead. You MUST run ./start.sh again to update .env with the new URL.

Step 3: Verify Webhook is Registered in Telegram

Open your browser and paste this URL (replace with YOUR values):

https://api.telegram.org/botYOUR_BOT_TOKEN/getWebhookInfo

Example:

https://api.telegram.org/bot123456789:ABCdefGHIjklMNOpqrsTUVwxyz/getWebhookInfo

Expected successful response:

{
  "ok": true,
  "result": {
    "url": "https://YOUR-NGROK-URL.ngrok-free.app/webhook/telegram",
    "has_custom_certificate": false,
    "pending_update_count": 0,
    "ip_address": "1.2.3.4",
    "last_error_date": 0,
    "max_connections": 40,
    "allowed_updates": ["message", "callback_query"]
  }
}

If the URL is empty or different, the webhook is NOT registered. Continue to Step 4.

Step 4: Set Webhook Manually via Telegram API

If webhook is not registered, manually set it:

# Replace YOUR_BOT_TOKEN and YOUR-NGROK-URL
curl -X POST "https://api.telegram.org/botYOUR_BOT_TOKEN/setWebhook" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://YOUR-NGROK-URL.ngrok-free.app/webhook/telegram"}'

Example:

curl -X POST "https://api.telegram.org/bot123456789:ABCdefGHIjklMNOpqrsTUVwxyz/setWebhook" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://f23bcce90eba.ngrok-free.app/webhook/telegram"}'

Expected response:

{
  "ok": true,
  "result": true,
  "description": "Webhook was set"
}

Step 5: Check n8n Executions

  1. Open n8n: http://localhost:5678
  2. Go to "Executions" tab
  3. Send a test message to your Telegram bot
  4. You should see an execution appear

If still no execution:

# Check n8n logs for errors
docker compose logs -f n8n

# Look for errors related to:
# - Telegram
# - Webhook
# - 404 errors

Step 6: Verify Telegram Trigger Node

In n8n workflow:

  1. Click on "Telegram Trigger" node

  2. Check that:

    • βœ… Credential is selected (not empty with red error)
    • βœ… "On" is set to message
    • βœ… "Resource" is set to Message
    • βœ… "Event" is set to started
  3. Click the "Activate webhook" button if present

  4. Check the "Test node" button - it should work

Step 7: Full Reset if Nothing Works

Sometimes n8n webhook cache gets corrupted. Do a full reset:

# Stop everything
./stop.sh

# Wait 5 seconds
sleep 5

# Remove n8n data volume (WARNING: loses all data)
# Find volume name:
docker volume ls | grep n8n_data
# Then remove it:
docker volume rm <volume_name>

# Start fresh
./start.sh

# Wait for n8n to start (~30 seconds)
sleep 30

# Re-import workflow and reconfigure

πŸ”΄ No Executions Showing in n8n

Causes & Solutions:

Problem Solution
Workflow is not Active Click the toggle switch in top-right to turn Active (green)
Telegram Trigger not configured Configure credential and click "Save"
ngrok URL not updated in .env Run ./start.sh again
n8n hasn't reloaded Refresh browser (Ctrl+F5) or restart n8n: docker compose restart n8n
Webhook not registered with Telegram Follow Step 4 above to manually set webhook

πŸ”΄ ngrok URL Keeps Changing

Free ngrok accounts get a new URL every time you restart ngrok. Solutions:

  1. Use the automated script (recommended):

    ./start.sh  # Automatically updates .env with new URL
  2. Use ngrok paid plan ($5/month) for static URL:

  3. Use your own domain with reverse proxy (nginx, Cloudflare, etc.)

πŸ”΄ Workflow Not Auto-Importing on Start

Symptoms: Workflow missing after ./start.sh, need to manually import

Solutions:

# 1. Check n8n container logs for import errors
docker compose logs -f n8n | grep -i "import\|workflow"

# 2. Check init script logs
docker exec smart-home-assistant-n8n-1 cat /tmp/n8n-init.log

# 3. Force reimport the workflow
./start.sh --reimport

# 4. If still failing, manually import via n8n UI:
#    - Click Menu (☰) β†’ Workflows β†’ Import
#    - Select smart_home_assistant.json
#    - Click Import

Common causes:

  • n8n didn't fully start before init script tried to import
  • n8n API was not responding
  • Workflow file not found in container (check docker-compose.yml volumes)

πŸ”΄ Stop/Start Not Preserving Data

Symptom: Data disappears after ./stop.sh and ./start.sh

Cause: Using docker compose down instead of docker compose stop

Solution:

# CORRECT - preserves data
./stop.sh                  # Uses docker compose stop

# WRONG - deletes data
docker compose down        # Deletes containers and volumes!

# Always use ./stop.sh for stopping
# Only use 'docker compose down' if you want to RESET everything

πŸ”΄ PostgreSQL Connection Error

Error message: "ECONNREFUSED 127.0.0.1:5432"

Solution:

# Verify PostgreSQL is running
docker compose logs postgres_memory

# Check connection from n8n credential setup:
# - Host: postgres_memory (NOT localhost)
# - Port: 5432 (internal Docker port, NOT 5444)
# - User: pguser
# - Password: pgpass
# - Database: memorydb

πŸ”΄ Port 5678 Already in Use

Error: "bind: address already in use"

Solution:

# Check what's using port 5678
lsof -i :5678

# Kill the process (if it's old n8n)
kill -9 <PID>

# Or change the port in docker-compose.yml

πŸ”΄ OpenAI API Errors

Common errors:

Error Cause Fix
"Invalid API key" Wrong key or expired Check OpenAI API key in n8n credentials
"Rate limit exceeded" Too many requests Wait or upgrade OpenAI account
"Quota exceeded" No credits Add credit card to OpenAI account
"Model not available" Account doesn't have GPT-4 Use gpt-3.5-turbo or upgrade account

πŸ”΄ Google OAuth Issues

Error: "Invalid redirect URI"

Solution:

  1. Check your ngrok URL is correct in .env
  2. In Google Cloud Console, verify redirect URI matches exactly:
    https://YOUR-NGROK-URL.ngrok-free.app/rest/oauth2-credential/callback
    
  3. If ngrok URL changed, update Google Cloud Console
  4. Delete old credential in n8n and create new one

General Debugging Steps

  1. Restart everything:

    ./stop.sh && sleep 5 && ./start.sh
  2. Check all logs:

    docker compose logs -f
  3. Test ngrok tunnel:

    curl https://YOUR-NGROK-URL.ngrok-free.app
    # Should return: 404 Bad Request (this is normal)
  4. Test Telegram API:

    curl https://api.telegram.org/botYOUR_BOT_TOKEN/getMe
    # Should return bot information
  5. Clear n8n cache (if things are stuck):

    docker compose exec n8n rm -rf /home/node/.n8n/cache
    docker compose restart n8n

Container won't start

# Check logs
docker-compose logs

# Remove and recreate
docker-compose down
docker-compose up -d

Reset n8n completely

docker-compose down -v
docker-compose up -d

Port conflicts

If ports 5678 or 5444 are already in use, edit docker-compose.yml:

ports:
  - "YOUR_PORT:5678" # Change YOUR_PORT

Development

Update Workflow

  1. Make changes in n8n UI
  2. Export workflow: Workflows > ... > Download
  3. Replace smart_home_assistant.json
  4. Commit to version control

Update n8n Version

docker-compose pull
docker-compose up -d

Configuration Notes

  • n8n runs on port 5678
  • PostgreSQL runs on port 5444 (mapped from internal 5432)
  • Data persists in Docker volumes: n8n_data and pgdata
  • Webhooks require a public URL (ngrok or domain)

Credentials Summary

Here's a complete list of all credentials you need:

Environment Variables (.env file)

Variable Description Example
N8N_USER n8n admin username admin
N8N_PASS n8n admin password your_secure_password
NGROK_URL Public webhook URL https://abc123.ngrok-free.app
PG_USER PostgreSQL username pguser
PG_PASS PostgreSQL password your_db_password
PG_DB PostgreSQL database name memorydb
oauth_redirect_uri OAuth callback URL https://abc123.ngrok-free.app/rest/oauth2-credential/callback

n8n Workflow Credentials

Credential Type Where to Get Used By Nodes
Telegram Bot Token @BotFather on Telegram Telegram Trigger, Send a text message
OpenAI API Key platform.openai.com/api-keys OpenAI Chat Model
PostgreSQL Connection Self-hosted (Docker) Postgres Chat Memory
Google OAuth (Client ID + Secret) Google Cloud Console All Google Sheets & Calendar nodes
Google Sheet IDs From Google Sheets URLs Get/Append Google Sheets nodes
Google Calendar Email From Google Calendar Get/Create Calendar Event nodes

Security

CRITICAL: Before publishing to GitHub:

  1. NEVER commit .env file with real credentials
  2. .env is already in .gitignore - verify this before committing
  3. Change default passwords (N8N_PASS, PG_PASS) to strong, unique passwords
  4. For production:
    • Use environment variable management (AWS Secrets Manager, etc.)
    • Enable HTTPS with proper SSL certificates
    • Restrict PostgreSQL port access (remove port mapping or use firewall)
    • Use strong, randomly generated passwords (20+ characters)
    • Enable 2FA on Google account used for OAuth
    • Regularly rotate API keys
    • Monitor OpenAI API usage to prevent unexpected costs
    • Set up rate limiting on Telegram bot if needed

Workflow Export Note: The exported JSON (smart_home_assistant.json) does NOT contain credential values - only references to credential names. It's safe to share publicly.

Support

For issues with:

License

[Your License Here]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages