Getting started with the Telegram node

So I’ve created a Telegram “app” for the API credentials at Authorization . Telegram calls them:

App api_id
App api_hash

I just assume the “Access Token” refers to the api_hash?

When I create the Telegram node I’ve selected the credentials and “Send Message” but how do I get the chat ID?

Sorry, I do not know anything about Telegram apps. But what you need is an access token and you can create ith with the “botfather”. You can find information about it here:

You normally react to incoming messages you receive via the Telegram Trigger Node. In the data received you will also get the chat ID. A basic Telegram Bot workflow can be found here:

1 Like

That’s what I expected until I read about “API”. A little confusing.
It would be great if the node would help with the chatID - because that’s a bit of PITA to obtain as of now.

Here is what you need to do:

  1. talk to the botfather at Telegram: Contact @botfather and create the bot
  2. add the bot to a group
  3. write something into the group looking like this /test something
  4. replace <TOKEN> and open the following URL in a browser: https://api.telegram.org/bot<TOKEN>/getUpdates
  5. the json has a chat:{id:-12345 … that id is what you need

Other options is to invite other bots that reveal the id and then kick them again.

2 Likes

hm, do not totally understand. When I did create the integration and tested it, it seemed all quite easy.

I simply:

  1. created the bot
  2. opened a conversation directly to it
  3. created the Trigger-Node

Then every time I wanted to test something I did simply write something into the conversation I had open with my bot. The Trigger Node then got the data (including chat ID) and I could then use it to directly send the response.

I know @mooghermez is actively creating bots with n8n. Maybe he has some more insight into it and how he develops.

I did not create a trigger node. I used it to send. Hence it needs the chat id.

@tcurdt to get a chat ID you can use the @get_id_bot

In my case, it also matches the user_id, so maybe that’s a rule as well.

4 Likes

As you know (@tcurdt) probably:
1- you should create your bot with @botfather in telegram.
2- In n8n in credential you should add your bot token.
3- If you use telegram trigger in a workflow, when you chat by your bot in telegram you can get all needed information in telegram trigger in n8n (also chat id and etc.) Also as @brunoamaral said you can find chat id by @get _id_bot.

Sure - the above way is just without inviting the @get_id_bot into the group and then kicking it out again. (IIRC that’s how it works, right?)

Really I didn’t use @get_id_bot.
I find my data just from telegram trigger in n8n.

I guess one could also create a trigger, find out the id and then remove it again.
There are plenty possibilities :slight_smile:

In my use case I didn’t need a trigger. Hence that wasn’t so clear in the first place.