Telegram WebHook Setup

Hi i’m completly new about this localhosting and automatization.

I being stuck for a while with the setting up of the https for work with Telegram Bots. I have already a https which is antagora.de and also already coded it in to the docker yml but still not working. I would be extremely gratefull if somebody gave me a hand on this.


  • n8n version:1.80.5
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Window 11

Seems like your using localhost as a webhook, which is not https

http://localhost:5678/webhook/fffb4aa4-ac38-4465-b9b2-9591a7304ae7/webhook 

That is because it is a self hosted n8n. My suggestion would be to create a free account with ngrok service https://ngrok.com/

If have been using this commandline to get my n8n running on docker
There you can see the places where you would use the url provided by ngrok
In a commanline. you start the service with

( I edited is a bit to remove personal info)

docker run -itd \
 --name n8n \
 --restart always \
 -p 5678:5678 \
 -e GENERIC_TIMEZONE="Europe/Amsterdam" \
 -e TZ="Europe/Amsterdam" \
 -e WEBHOOK_TUNNEL_URL="<ngrok url>/" \
 -e WEBHOOK_URL="<ngrok url>" \
 -v n8n_data:/home/node/.n8n \
 -v /Users/......../n8n-data/cert:/home/node/.n8n/cert \
docker.n8n.io/n8nio/n8n:latest

You start your forwarding with:

ngrok http http://localhost:5678

There you find the forwarding url:

Use this url on the place holders in the commandline or yml file

You can work this out in your YML file.

You will have to let telgram know what webhook to use.
You will need your telegram token

https://api.telegram.org/bot[telegram token]/setWebhook/[ngrok forwarding address]

if this solves your problem then please hit the ‘solution’ button

1 Like

what’s the actually?

If you have an account with ngrok you can execute an command in the terminal/commandline tool.

ngrok http http://localhost:5678

It will give you the url. (its called forwarding url) and ends with

.ngrok-free.app

See my previous post.

Windows

I made a file “run-n8n.ps1”
Then edited it:

# Prompt user for ngrok HTTPS URL
$ngrokUrl = Read-Host "Enter your ngrok HTTPS URL (e.g. https://1234-56-78-90.ngrok-free.app)"

# Strip trailing slash
$ngrokUrl = $ngrokUrl.TrimEnd('/')

# Extract host from URL
$n8nHost = $ngrokUrl -replace '^https://', ''

# Set environment variables for Docker
$envVars = @(
    "--env", "N8N_HOST=$n8nHost",
    "--env", "N8N_PROTOCOL=https",
    "--env", "WEBHOOK_TUNNEL_URL=$ngrokUrl/",
    "--env", "WEBHOOK_URL=$ngrokUrl/",
    "--env", "N8N_RUNNERS_ENABLED=true"
)

# Run Docker container
docker run -it --rm `
    --name n8n `
    -p 5678:5678 `
    -v n8n_data:/home/node/.n8n `
    @envVars `
    docker.n8n.io/n8nio/n8n

PowerShell command:
./run-n8n.ps1

Then, I pasted the link of ngrok in the PowerShell by: ngrok http http://localhost:5678

Linux Ubuntu

I made a file: run-n8n.sh

Do it if required:

chmod 777 .\run-n8n.sh

chmod +x .\run-n8n.sh

Then edit it


# Prompt for ngrok HTTPS URL
read -p "Enter your ngrok HTTPS URL (e.g. https://1234-56-78-90.ngrok-free.app): " NGROK_URL

# Strip trailing slash if any
NGROK_URL=${NGROK_URL%/}

# Extract host from URL
N8N_HOST=$(echo "$NGROK_URL" | sed -E 's|https://||')

# Export env vars (optional – mainly for local debugging)
export N8N_HOST="$N8N_HOST"
export N8N_PROTOCOL="https"
export WEBHOOK_TUNNEL_URL="$NGROK_URL/"
export WEBHOOK_URL="$NGROK_URL/"
export N8N_RUNNERS_ENABLED="true"


# Run n8n with Docker
sudo docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  -e N8N_HOST="$N8N_HOST" \
  -e N8N_PROTOCOL="https" \
  -e WEBHOOK_TUNNEL_URL="$WEBHOOK_TUNNEL_URL" \
  -e WEBHOOK_URL="$NGROK_URL" \
  -e N8N_RUNNERS_ENABLED="$N8N_RUNNERS_ENABLED" \
  docker.n8n.io/n8nio/n8n