How to use "telegram-mtproto" in n8n?

I want to read the group and private messages of my own user account in Telegram without bot. As far as I can see, it is possible to read messages through bots in telegram nodes in n8n. But I want to do this with my own account. I did not see an option for this in nodes.

The link below explains how to do this with nodejs. I wonder how can I use telegram-mtproto on n8n?

1 Like

Welcome to the community @mutluozkurt

You will need to create your custom image that adds that dependency. Once you have the dependency, you can use it on a function node or create a custom node that uses that library.

Hey @mutluozkurt!

Welcome to the community :tada:

To add to what Ricardo suggested, you can also install the npm package on your server, add it to your container volume, make it accessible to n8n by setting the NODE_FUNCTION_ALLOW_EXTERNAL variable, and then use it in the Function node.

Please note that with this approach you might have to also add the dependencies of the npm library.

still no way to have telegram node in n8n for personal accounts ?

1 Like

Hey @kravzz1,

No we use the bot APIs for our node, I am not sure if there is an official telegram api for users I will take a look later and see if they document anything.

Yes sir, they have an official method called MTProto API, which allows the use of Telegram API with more features such as larger file sizes, personal accounts, etc.

I always forget about the protocol itself even though it is in the title of the post, So we still only use the Bot API but you can manually implement mtproto if you want to use it.

AFAIK, It’s already done by the community: https://www.npmjs.com/package/n8n-nodes-telepilot

I spotted that come in the other day, Personally it won’t be a package I will use as the source is hidden and it looks to run everything through a third party service. I think the API endpoint it uses has an expired SSL certificate on it as well but I suspect it is still new and some of this will be tweaked over time. It sounds like an exciting project though.

1 Like

I’m really glad n8n community has already spotted n8n-nodes-telepilot plugin that we published to npmjs.com recently.

Project is currently in testing phase and we expect to polish everything up during next weeks. For now, main challenges are solved and we are tweaking it here and there.

Telepilot is based on MTProto protocol and serves the goal of providing way to easily automate interactions with Telegram messenger in a way which is securing user’s data and respects user’s privacy.

It’s supposed to be run on open-source version of n8n that is in full control of the user.

MTProto events, that are received by the module, are processed on the machine where n8n is installed and are not sent anywhere else except Telegram servers.

Though telepilot is fully based on opensource stack, it’s source code is currently closed until we have clear future vision of the project.

Userbot MTProto Telegram is different from other n8n integrations, as it requires usage of prebuilt binary/lib (which is actually taking over communication with Telegram servers), that needs to be provided for each OS, architecture and support multiple n8n running scenarios (npm, docker). For the time being there is no working open-source nodejs library like that. Perhaps someone will be able to make such n8n integration work more easily with python, this we have not checked tried.

Making whole chain work - from docker/OS with different architectures, through libc, c/c++ modules, N-API, Javascript/Typescript up to n8n workflows - took us substantial amount of time.

Furthermore, to make it easily usable as n8n plugin, modules need to be prebuilt for different environments and platforms, tested and distributed which also adds to maintanance cost of the whole thing which needs to be covered somehow.

@Jon telepilot does not expose or forward Telegram messages to anywhere: doing Userbot integration via third-party API would have been way more easier job, but it would require user to authorize MTProto client, that is running somewhere for accessing all their messages. This is not what we want - we want user to be in full control of their data. The question is how to make this approach sustainable.

The whole case is a bit tricky. We are not able to make it open-source and monetize by providing preinstalled SaaS version of the plugin on subscription basis: this contradicts the idea of giving user full control and ownership of their Telegram data. Furthermore, this would require approval from n8n side since it is against ToS to provide managed n8n hosting.

You probably have noticed that telePilotApi credentials are calling http://ls.telepilot.co HTTP endpoint. This is very basic “license check”: GET request with license_code is being sent to licensing server and if invalid answer is received, node will not be able to establish MTProto connection. We added it for now since plugin is being tested and is not yet “released”. It’s on purpose HTTP so that anyone who wants can run it in a VM (or by using network sniffer) and check which extra TCP connections are being created when the plugin is installed. The data is not encrypted.

We are currently working on documentation and will publish more relevant technical details soon.

I’m happy to help or answer any questions which are related to n8n-nodes-telepilot node that n8n community has.

1 Like

So, it’s not a free community node. That’s why I tried to use it, and sadly, it does not work. GLWS.

Current build can only be installed on n8n, which is running in official n8nio/n8n docker container (be it via Docker or docker-compose, this should not matter). MTProto prebuilts for npm (in linux), windows and macos environments are not included in latest package.
Also, if it cannot reach ls.telepilot.co (for the preliminary “ping”) it will not establish MTProto connection with Telegram server.

@Nskha how are you running your n8n and which version are you on? Perhaps this could be a problem why it did not work for you.

Hey @telegram-copilot,

Welcome to the community :raised_hands:

We have the same thing when it comes to creating something that is sustainable, You are correct it was the license URL I spotted which was using an https endpoint when I checked it last. Sadly though I still don’t think this is going to be something I would use for the reasons previously mentioned :slight_smile:

You may be interested to know that we do have some partners who do have a license to offer a paid hosted version of n8n for their customers so that is something that can happen. This will be something to watch to see it take off as I suspect there will be a lot of folk interested in this.

I installed it using the cloud app and Docker, following the official n8n documentation with the latest update. Here is my settings page. I believe there is a missing field for displaying the QR code scan.

Hello @Nskha, oh wow, thank you for your feedback!

QR Code was not put on credentials dialog intentionally.
Configuring credentials is prerequisite to use TelePilot, but in order to actually Log In, you need to use “Login with QR Code” in a workflow.
I understand this can be a bit misleading, however we did it like this in beta version due to limitations in that Community N8N Nodes: testedBy methods are mapped at build time and cannot be resolved for nodes that have been added at runtime, i.e. community nodes (this could also be expected behaviour though, github issue still needs to be opened, ). But this can also be seen as better way to log in, because in this way user is able to perform log out and log in explicitely, and has more control in terms of what is happening between n8n and Telegram servers.

You could check out our guide on how Login with QR Code can be done: Logging into Your Telegram Account with TelePilot Made Easy
Documentation is currently being created, so you will see some parts on npmjs.com and something documented on the website.

If something goes wrong, you can use “Remove td database” action to clean up all local tdlib files and establish new connection (it’s also documented on the page).

I hope this helps! Looking forward to hearing from you.

1 Like

Host: Hetzner Cloud (Docker SE)

1 Like

I see, you are running n8n in docker on arm64. This architecture is not yet supported by the plugin, currently we distribute plugin only for “docker x64”. I personally am using “darwin arm64” build on my macbook to test, so this is possible but it is not yet included in community plugin package.

We are working on supporting more architectures and I will notify you as soon as “docker arm64” is enabled.
If you like, you can also check out our Telegram Channel - you can find it on npmjs.com plugin page. We post all the latest updates and how-tos in there.

Thanks a lot for your feedback @Nskha !

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.