Pass Telegram (and other) credentials through an expression

Some actions in Telegram require sending HTTP requests with API token in the url, like:<token>/getFile?file_id=<file_id>
to get the ID of the uploaded file.

Is it possible to use an expression to pass a node credentials in an expression? Hardcoding them wouldn’t be a good idea. I didn’t find any key in the list of variables.

As far as I know, that is not possible. What you can do it’s to set the API key in the env variable and reference that using $env variable.

Thank you. Looks difficult for I don’t know how to utilize the script in the reference.
I’ll create a feature request for that.

You do not need the script. Just set the env variable and then reference it as {{$env.VARIABLE_NAME }}

I mean, it’s completely unclear for me, how to set such a variable. I should write somewhere text like this?

1. FROM node:lts-alpine
* # pass N8N_VERSION Argument while building or use default
2. ARG N8N_VERSION=0.98.0
* # Update everything and install needed dependencies
3. RUN apk add --update graphicsmagick tzdata
* # Set a custom user to not have n8n run as root
4. USER root
* # Install n8n and the also temporary all the packages
5. # it needs to build it correctly.
6. RUN apk --update add --virtual build-dependencies python build-base && \

Not at all. That is Jan explaining how to upload the dockerfile to test this feature. But, that’s is before this feature was generally available. Now that is available that is not needed. The only thing needed it’s to set up the env variable and then use it in the workflow. How did you deploy n8n? Or are you using n8n cloud?

I installed it on my own server. You are talking about this part of the .yml file?

In the .env file do API_KEY_TELEGRAM=yourapikry. The name is an example, you can call it whatever you want.

That is step 6 of the server setup Server Setup | Docs

Make sure you restart the container so it reads the new env variable.

Later in the http node to use it you do: {{env.API_KEY_TELEGRAM}}

Thanx. I was already expreimenting. I added a line and restarted the containers.
I might tell that the new variable is not reacheable
This is how it’s written in the .yml file:
And this is how it’s delivered:

Not all of the system variables are reachable:


Can you run it with the expression no matter if it’s in red? It should work. If you read below, that happened to another user, and it still works. It might be an issue with the UI resolving the value.

1 Like

It’s very confusing, but it actually works!
Thank you. Hope this will be fixed.

Great that it worked. Have fun.