N8n local with tunnel to enable for example telegram message trigger

Does anybody know how to setup/start local n8n with a tunnel for webhooks needing an https:// … server eg. telegram message trigger?

I have heard that it is possible with ngrok (do not know how) and
also n8n has an internal tunnel function but how to setup?

thanks

I did it through cloudflare and it was not too difficult, certainly nothing like getting a supabase container going. I did a cloudflare container in docker with a webhook and a secure tunnel. There are some guides out there on how to do it. It takes a bit of tinkering but pretty straightforward. DNS is a careful consideration and do not make the local “loopback” thing some guides tell you too as an A Type or it will always try to hit that first…you’ll see what I mean just stick to a cname with your webhook. Also easiest if you register a domain and it gives you something you can use for other stuff as well and its 10USD and cloudflare has services all over.

Thanks John, need to look into that further as I have no knowledge about tunneling.
Cloudflare seems to be a good option and I also have (some) domains but I do not host n8n on it. Is it possible to use it as a public ULR in n8n ? With cloudflare or otherwise?
I had a look into cloudflare documentation but was overwhelmed with all the possibilities one have but it seems to be a good choice for other services as well.

If you follow along the documentation and just avoid that AName assignment it goes pretty smoothly. I did for exactly the reason you mentioned with Telegram needing https. I got stuck once or twice and my codellama provided some guidance and it was up and running. I use it multiple times a day to track transactions I make.

Do you mean the cloudflare documention? I struggle in setting the Base URL in n8n.

Hi John,

I saw your reply to yvesete about local hosting n8n behind cloudflare and handling telegram triggers through some documentation.

Could you please explain a bit more? I also followed the n8n documentation without the step “Add a record to domain” as Cloudflare handles this by itself. Currently I only have a CNAME record with my N8N_HOST url and this is also the same for webhook. But still I couldn’t get it to work.

Would you please suggest me a comprehensive and up-to-date guide or your way of doing it?

Kind regards, Batu

I have got a tip to read this:

looks very good. Up to now I tried 4B the ngrok because I have it allready but I did not get it to work. Do not know whether it is ngrok or n8n local because connection to the tunnel works but it can not post. n8n telegram message uses a different token as the bot has for what ever reason.

I will try cloudflare tomorrow and also maybe try to host on a VPS, maybe oracle free tier.

Heres what I have for the service if it helps:

  cloudflared:
    image: cloudflare/cloudflared:latest
    container_name: cloudflared
    restart: always
    networks: 
      - localai_default
    command: tunnel --loglevel debug run --cred-file /etc/cloudflared/YOU_HAVE_TO_GET_THIS_CRED@CLOUDFLARED.json
    environment:
    - NO_AUTOUPDATE=true
    volumes:
    - /opt/localai/cloudflared:/etc/cloudflared:ro

As you can see you will generate and download that .json credfile and point to it and viola you have a tunnel.

Could it be another problem, tunneling with ngrok seems to work.
Tested it with curl and :slight_smile:

tested it with (xxxxx = bot ID):

curl “https://api.telegram.org/xxxxxxxxxxxxxx/getWebhookInfo

{“ok”:true,“result{“url”:”",“has_custom_certificate”:false,“pending_update_count”:9,“allowed_updates”:[“message”]}}%

Strange is ok is true but in result url there is only a comma …

This package doesn’t work with tunnels from ngrok and cloudflare(d) for telegram trigger on my machine. I tried every possibility and give up.

Didn’t give up I tried GitHub - Joffcom/n8n-ngrok
and it works just fine.
Next step is to include this ngrok setup into local-ai-packed .env and docker-compose.yml
let you know the outcome

1 Like

Nice!! Yeah I’d love to see it!

Can’t get the package including ngrok running. I inserted

x-ngrok: &service-ngrok
container_name: ngrok
image: ngrok/ngrok:latest
environment:
- NGROK_AUTHTOKEN=${NGROK_TOKEN}
command:
- “start”
- “–all”
- “–config”
- “/etc/ngrok.yml”
#networks:
# - n8n-network
volumes:
- ./ngrok.yml:/etc/ngrok.yml

in the docker-compose.yml, have the ngrok token in the .env and an ngrok.yml file but it is not created with docker compose (through start_services.py)
no error but ngrock container/image is not created.
I am blind right now and would appreciate any help … :slight_smile:

edit: got it to work ngrok and n8n not in the same docker compose stack doesn’t work but ngrok manuall startet with:

“ngrok http --url my-ngrok-url.ngrok.free.app 5678”

works
(replace my-ngrok … with your registered free https url with ngrok)

1 Like