# Telegram

Integración de PandoraFMS con un bot de Telegram

# Telegram

Paso a paso para realizar la integración con un bot de Telegram

<p class="callout info">**NOTA: Esta guia se encuentra en construcción**</p>

<span style="font-weight: 400;">[![TelegramLogo.png](https://pandorafms.com/guides/public/uploads/images/gallery/2020-12/scaled-1680-/telegramlogo.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2020-12/telegramlogo.png)</span>

# <span style="font-weight: 400;">Introducción</span>

<span style="font-weight: 400;">Conector CLI de bots de Telegram para usar en alertas de pandora </span>

# <span style="font-weight: 400;">Matriz de compatibilidad</span>

- <span style="font-weight: 400;">Python3 para source code </span>
- <span style="font-weight: 400;">Linux x64 para compilado</span>

# <span style="font-weight: 400;">Requerimientos</span>

<span style="font-weight: 400;">Los requisitos son los siguientes:</span>

- <span style="font-weight: 400;">Una cuenta de Telegram para crear el bot</span>
- <span style="font-weight: 400;">Añadir el bot al grupo de notificación</span>
- <span style="font-weight: 400;">Obtener la id del grupo</span>
- <span style="font-weight: 400;">(solo para código fuente) Tener instalado python3 en el servidor de Pandora con el módulo: request.</span>

[<span style="font-weight: 400;">SIGUIENTE &gt;</span>](https://pandorafms.com/guides/public/books/notificaciones-en-pandorafms-19c/page/configuracion)

# Configuración

## <span style="font-weight: 600;">Creación del BOT en Telegram</span>

<span style="font-weight: 400;">Desde una cuenta de Telegram se debe escribir</span>*<span style="font-weight: 400;"> /start</span>*<span style="font-weight: 400;"> al usuario </span>**BotFather** <span style="font-weight: 400;">([https://telegram.me/botfather](https://telegram.me/botfather))</span> <span style="font-weight: 400;">para crear un bot.</span>

<span style="font-weight: 400;">Nos devolverá una serie de parámetros e instrucciones que podemos hacer para la creación y manipulación de bots.</span>

[![image-1608158507569.png](https://pandorafms.com/guides/public/uploads/images/gallery/2020-12/scaled-1680-/image-1608158507569.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2020-12/image-1608158507569.png)

<span style="font-weight: 400;">Nosotros utilizaremos la opción </span>***/newbot*** <span style="font-weight: 400;">con la que crearemos un nuevo bot.</span>[  ](https://pandorafms.com/guides/public/uploads/images/gallery/2020-12/image-1608158507569.png)<span style="font-weight: 400;">Nos preguntará el nombre que queramos poner a nuestro bot, en mi caso he seleccionado </span>***Pandora\_FMS\_Test\_bot*** <span style="font-weight: 400;">tu puedes poner el que prefieras.</span>

<span style="font-weight: 400;">Ahora nos pedira un id de usuario para el bot este tiene que terminar en \_bot en este caso utilizaré el mismo. </span>***Pandora\_FMS\_Test\_bot***

<span style="font-weight: 400;">Ahora nos devolverá la información de nuestro bot y algunas instrucciones para su administración, nosotros copiaremos y guardaremos el API token que es con el que nos autenticaremos como ese bot</span>

<span style="font-weight: 400;">[![PandoraFMS-NTelegram01.png](https://pandorafms.com/guides/public/uploads/images/gallery/2021-01/scaled-1680-/pandorafms-ntelegram01.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2021-01/pandorafms-ntelegram01.png)</span>

<span style="font-weight: 400;">  
  
</span>

[&lt; ANTERIOR](https://pandorafms.com/guides/public/books/notificaciones-en-pandorafms-19c/page/telegram) [SIGUIENTE &gt;](https://pandorafms.com/guides/public/books/notificaciones-en-pandorafms-19c/page/crear-un-grupo-y-anadir-el-bot)

# Crear un grupo y añadir el bot

<span style="font-weight: 400;">Para crear un grupo desde Telegram simplemente debemos hacer clic en crear grupo y seleccionar los usuarios que estarán en ese grupo es importante que uno de esos usuarios sea nuestro bot para poder enviar mensajes a ese grupo específico también podemos simplemente añadir el bot a un grupo existente.</span>

[![PandoraNTelegram02.png](https://pandorafms.com/guides/public/uploads/images/gallery/2021-01/scaled-1680-/pandorantelegram02.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2021-01/pandorantelegram02.png)

[&lt; ANTERIOR](https://pandorafms.com/guides/public/books/notificaciones-en-pandorafms-19c/page/configuracion) [SIGUIENTE &gt;](https://pandorafms.com/guides/public/books/notificaciones-en-pandorafms-19c/page/obtener-la-id-del-grupo-para-enviar-mensajes-desde-el-cli)

# Obtener la id del grupo para enviar mensajes desde el CLI

<span style="font-weight: 400;">Ahora necesitamos obtener la id del grupo en el que hemos añadido nuestro bot, hay diferentes formas de hacerlo, pero de las más sencillas es añadir otro bot que extrae esa información muy fácilmente </span>**GetIDs Bot** <span style="font-weight: 400;">(</span>[<span style="font-weight: 400;">https://t.me/getidsbot</span>](https://t.me/getidsbot)<span style="font-weight: 400;">).</span>

<span style="font-weight: 400;">Lo añadimos al grupo que queremos conocer el id y nos dará una serie de instrucciones para su uso. Pero solo con añadirlo ya nos dará la información que necesitamos que es la id del grupo.</span>

<span style="font-weight: 400;">[![PandoraFMS-NTelegram03.png](https://pandorafms.com/guides/public/uploads/images/gallery/2021-01/scaled-1680-/pandorafms-ntelegram03.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2021-01/pandorafms-ntelegram03.png)</span>

<span style="font-weight: 400;">Una vez tengamos la id del grupo lo copiamos y guardamos, podemos eliminar este bot del grupo si queremos, ya ha cumplido el objetivo de darnos el id.</span>

<span style="font-weight: 400;">[&lt; ANTERIOR](https://pandorafms.com/guides/public/books/notificaciones-en-pandorafms-19c/page/crear-un-grupo-y-anadir-el-bot) SIGUIENTE &gt;</span>