Is it possible to use the telegram node to post to a (my own) telegram channel?

I tried to use the telegram node to use a telegram bot to send a message to a telegram channel where the bot is an admin.

I have both the chat ID and the name of the channel starting with @

Nothing I have tried so far seems to work.
(neither using the chat ID I got by adding the @username_to_id_bot bot as a member to the channel nor using the channel name itself)
I’ve tried a couple other stupid things not worth mentioning. :slight_smile:

it gives this error:

"message": "400 - {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}",

"name": "Error",

"stack": "Error: Request failed with status code 400 at createError

I can get the same n8n node to send a message to a chat I have going between me and the bot. But I can’t get it to send an update to the channel by changing over to its ID. I’m wondering if maybe that’s just not supported? Or maybe I just THINK I have the chat ID for the channel, but I don’t really. :slight_smile:

Thanks to anybody very kindly for their time and help. :slight_smile:

Hi @MJ_33

Can you try opening this URL in your Browser?

https://api.telegram.org/bot{bot_token}/sendMessage?chat_id={chat_id}&text=hello

Make sure to replace {bot_token} with your actual bot token and {chat_id} with your actual chat ID.

Please note that Chat ID of your Telegram Channel starts with a prefix of -100 something like this for example -1001367229836

If it’s working correctly then place the working chat ID in telegram node.

4 Likes

Thank you for the help. It gave me another thing to try at least. It turns out I had the right chat ID. But for SOME reason it won’t work without a minus sign in front of it. I wasn’t aware that needed to be included. Thank you for the help! :smile:

3 Likes

For what it’s worth, when the channel is public, the @username_to_channel works well in place of the chat ID. Also, n8n receives a response with the chat ID after sending a message using the channel’s username. So that’s another handy way to get the chat ID. Just make sure to include the @ symbol if you’re using the username. It is required :slight_smile:

I found the relevant section on this really long page, thanks to your help:
(and that’s where I found mention of the channel name as an alternative)

2 Likes

Good to know. Glad it helps.

Enjoy :tada:

1 Like

For anyone else who may run in to difficulty with this, a particular stackoverflow discussion (linked below) was also helpful to me for finding the chat ID of the channel (before I made it public, etc.)

The easiest way I found was from this suggestion:

Found another one easiest way : Just send to @username_to_id_bot (Telegram: Contact @username_to_id_bot) bot your invite link to your private channel, it will return it’s ID . Simplest level : maximum! :slight_smile:

The suggestions about getting it from the address bar are also easy (and not dependent on a bot), only problem is that the new version of Telegram on the Web doesn’t have it in the address bar. But you can still get it from the legacy version: Telegram Web

You have to add the -100 (rincluding the minus sign) to the beginning of the partial ID in the address bar. See discussion for more details:

2 Likes

thanks for this haha

1 Like