Set up Telegram integration using the discourse-chat-integration plugin

This howto describes how to setup the Telegram provider included in discourse-chat-integration.

Install

If you haven’t already, install the discourse-chat-integration plugin

Setup Telegram

  1. Talk to the Telegram “Botfather” :robot: and setup a new bot. detailed instructions here
  2. Make sure to copy the token that the BotFather gives you. It will look something like this:
    110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
    

Setup Discourse

  1. In your site settings, paste the token you got earlier into the chat integration telegram access token setting, and save it

  2. Enable the chat_integration_telegram_enabled setting, and save it

  3. Go to the Plugins tab, then Chat Integrations

  4. Go to the Telegram tab

    • Note: if the Telegram tab is not visible, it means something went wrong when connecting to their API. You should check your site logs, then try again by re-enabling the chat_integration_telegram_enabled setting

Adding a channel

  1. Add your bot to a group chat on telegram (or just start a private chat with it)

  2. You should receive a message like this

    If not, try sending a message which starts with /getchatid

  3. Copy the Chat ID. If there’s a minus sign before it, make sure to include it - it’s very important!

  4. Go to your discourse admin panel, Plugins , Chat Integrations , Telegram

  5. Click Add Channel

  6. Enter a name for the channel (this is only displayed in the discourse admin panel, it can be anything)

  7. Paste the Chat ID from earlier into the box, then click Save Channel

  8. Use the Test button on the channel you just created to check that everything’s working. You should see something like this:

  9. Setup some “Rules” for your channel, according to the discourse-chat-integration instructions.

  10. Enjoy all the notifications :allthethings:

Using in a broadcast channel

To send notifications to a telegram broadcast channel, add the bot as a channel administrator, and then send the message

/getchatid

to obtain the chat ID. Then follow the instructions above to set up on Discourse.

In a broadcast channel you cannot use slash commands to manage rules.

Slash commands

You can use “slash commands” to control rules from Telegram. Check that the chat integration telegram enable slash commands site setting is enabled. Note that this gives anyone who can post in the group chat permission to edit the rules.

To learn how to use them, just send /help (or /help@my-forum-bot if in a group chat) and the bot will send you a help message.

Setting up command auto-complete (not necessary, but makes it much easier to use)

  1. Talk to the Telegram BotFather :robot:
  2. Select your bot, click edit bot, then edit commands
  3. Copy and paste this list of commands in
    watch - [category] [tag:name] | notify this channel for new topics and new replies matching rule
    follow - [category] [tag:name] | notify this channel for new topics matching rule
    mute - [category] [tag:name] | block notifications to this channel for posts matching rule
    remove - [rule number] | remove a rule (see /status for numbers)
    status - list all rules for this channel
    help - display a help message
    
  4. You should get a success message :slight_smile:

Other bot customisations

Talk to the Telegram BotFather :robot: to customise the name, description and icon for your bot. You should leave “Group Privacy” enabled, otherwise the bot will try and respond to every single message in a group chat.

Last edited by @JammyDodger 2024-05-26T07:10:54Z

Check documentPerform check on document:
26 Likes

Isn’t possible to allow users to subscribe to any public category? Without asking an admin to add their id to the whitelist?

1 Like

Not currently. It is possibly something that could be added (this is how Slack works), but given there is no concept of “organisations” on telegram, we would need to be careful that only public-facing categories are visible.

For per-user stuff you could try the telegram-notifications-plugin

1 Like

But that means two different bots :sweat_smile:
Anyway, thanks for such good plugins :+1:

1 Like

I’ve set it up, and it works with bot itself. However, when I set it up for public channel and try to test, an error “422 No Reason Phrase” occurs.
Could someone help me out?

Where does this error occur? In telegram, or in the “test” dialog in the Discourse admin panel?

Hi! I don’t see any submenu in the admin panel to manage Telegram settings

But i got my chat ID through the bot.

Hello,
Can you tell me what different Telegram notifications using the discourse-chat-integration plugin and Telegram Notifications Plugin (discourse-telegram-notifications)

Check the very top of this topic: Telegram Notifications Plugin (discourse-telegram-notifications) (the part with the :warning: next to it)

2 Likes

Whenever ppl reply the telegram bot message, it keeps informing the current chat id, telling ppl to configure something different on the admin panel.

I have the actual msg in portuguese:

Este chat está configurado WTTD Fórum. Configure-o no painel de administração. (ID do bate-papo:-1001093143218)

Google translated:

This chat is configured WTTD Forum. Configure it in the administration panel. (Chat ID: -1001093143218)

It’s quite annoying.

Also I’ve disabled chat integration telegram enable slash commands however still replies the command list.

Is there a way to make the bot ignore any reply?

where can we Add the channel in discourse? we don’t find nothing… caht bot is active and we get also the Chat-ID, thanks in advance

After enabling the telegram site settings, head to your admin panel, click “plugins” at the top, then “chat integration” on the left.

3 Likes

Hello, i don’t know is it ok right now, but after setting up bot in admin and adding bot to channel nothing happened.

Did you try using the “test channel” button. Did you get any errors?

1 Like

test channel button works, but i expect ‘welcome’ message like in guide.

I’m not sure which guide you are talking about. The chat-integration plugin doesn’t send a welcome message.

Once you have configured the channel, you need to add some “rules”. Then, topics/posts you make on your discourse forum will appear in Telegram.

1 Like

I’m talking about this instruction.

1 Like

Ah, I see. Try sending a message in the group, including the bot’s username (like @myforumbot). Then it should respond with that message.

3 Likes

I’ve configured everything successfully, except that whenever a new member leaves/adds into the telegram group which has the ‘chat integration bot’ as one of this groups member, I receive this msg in the telegram group:

New rule: /[watch|follow|mute] [category] [tag:name]
(you must specify a rule type and at least one category or tag)

  • watch – notify this channel for new topics and new replies
  • follow – notify this channel for new topics
  • mute – block notifications to this channel

Remove rule: /remove [rule number]
([rule number] can be found by running /status)

List rules: /status

Help: /help

This msg has started irritating every time a member is added or removed into/from the telegram group.
And if I create a telegram broadcast/channel and add the chat integration bot into that, this problem doesn’t arise therein.