Configurar la integración de Telegram usando el plugin discourse-chat-integration

Este howto describe cómo configurar el proveedor de Telegram incluido en discourse-chat-integration.

Habilitar el plugin

El plugin discourse-chat-integration viene incluido con Discourse. Si aún no lo has hecho, sigue las instrucciones principales del plugin para habilitarlo.

Configurar Telegram

  1. Habla con el Botfather de Telegram :robot: y configura un nuevo bot. Instrucciones detalladas aquí
  2. Asegúrate de copiar el token que te da el BotFather. Se verá algo como esto:
    110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
    

Configurar Discourse

  1. En la configuración de tu sitio, pega el token que obtuviste anteriormente en la configuración chat integration telegram access token y guárdalo.

  2. Habilita la configuración chat_integration_telegram_enabled y guárdala.

  3. Ve a la pestaña Plugins, luego Chat Integrations

  4. Ve a la pestaña Telegram

    • Nota: si la pestaña de Telegram no es visible, significa que algo salió mal al conectarse a su API. Debes revisar los registros de tu sitio y luego intentarlo de nuevo re-habilitando la configuración chat_integration_telegram_enabled.

Añadir un canal

  1. Añade tu bot a un chat grupal en Telegram (o simplemente inicia un chat privado con él).

  2. Envía cualquier mensaje al bot (o en el chat grupal donde se añadió el bot). Deberías recibir un mensaje con el Chat ID. También puedes enviar un mensaje que comience con /getchatid.

  3. Copia el Chat ID. Si hay un signo de menos antes, asegúrate de incluirlo, ¡es muy importante!

  4. Ve al panel de administración de tu discourse, Plugins, Chat Integrations, Telegram.

  5. Haz clic en Add Channel

  6. Introduce un nombre para el canal (esto solo se muestra en el panel de administración de discourse, puede ser cualquier cosa).

  7. Pega el Chat ID anterior en el campo y luego haz clic en Save Channel.

  8. Usa el botón Test en el canal que acabas de crear para verificar que todo funciona. Deberías ver algo como esto:

  9. Configura algunas “Reglas” para tu canal, de acuerdo con las instrucciones de discourse-chat-integration.

  10. Disfruta todas las notificaciones :allthethings:

Usar en un canal de difusión

Para enviar notificaciones a un canal de difusión de Telegram, añade el bot como administrador del canal y luego envía el mensaje

/getchatid

para obtener el ID del chat. Luego sigue las instrucciones anteriores para configurar en Discourse. Para canales públicos, también puedes usar el formato @nombredelcanal (ej. @miforochannel) en lugar del ID numérico del chat.

En un canal de difusión no se pueden usar comandos de barra para gestionar reglas.

Comandos de barra

Puedes usar “comandos de barra” para controlar las reglas desde Telegram. Comprueba que la configuración del sitio chat integration telegram enable slash commands esté habilitada. Ten en cuenta que esto da a cualquiera que pueda publicar en el chat grupal permiso para editar las reglas.

Para aprender a usarlos, simplemente envía /help (o /help@miforobot si estás en un chat grupal) y el bot te enviará un mensaje de ayuda.

Configurar el autocompletado de comandos (no es necesario, pero facilita mucho su uso)

  1. Habla con el BotFather de Telegram :robot:
  2. Selecciona tu bot, haz clic en edit bot, luego en edit commands
  3. Copia y pega esta lista de comandos:
    watch - [category] [tag:name] | notificar a este canal para nuevos temas y nuevas respuestas que coincidan con la regla
    follow - [category] [tag:name] | notificar a este canal para nuevos temas que coincidan con la regla
    mute - [category] [tag:name] | bloquear notificaciones a este canal para publicaciones que coincidan con la regla
    remove - [rule number] | eliminar una regla (ver /status para los números)
    status - listar todas las reglas para este canal
    help - mostrar un mensaje de ayuda
    
  4. Deberías recibir un mensaje de éxito :slight_smile:

Otras personalizaciones del bot

Habla con el BotFather de Telegram :robot: para personalizar el nombre, la descripción y el icono de tu bot. Debes dejar habilitada la opción “Group Privacy”, de lo contrario el bot intentará responder a cada mensaje en un chat grupal.

27 Me gusta

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

1 me gusta

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 me gusta

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

1 me gusta

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 Me gusta

Whenever users reply to the Telegram bot message, it keeps informing them of the current chat ID, telling them to configure something different on the admin panel.

I have the actual message 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 for 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, but it still replies with 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

1 me gusta

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

3 Me gusta

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 me gusta

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 me gusta

Estoy hablando de esta instrucción.

1 me gusta

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 Me gusta

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.