• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Build a No-Code AI Telegram Bot with n8n (On-Premise & Free)

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Create a fully functional AI-powered Telegram bot without writing a single line of code! In this tutorial, you'll learn how to set up n8n locally and connect it to Telegram and an AI model—completely free and on-premise.

Prerequisites

  • Node.js (v14 or higher) installed on your system
  • Telegram account to create a bot using BotFather
  • OpenAI API key or Google AI credentials for LLM integration
  • n8n (installed using npx) for automation workflows
  • ngrok (optional) to expose local webhooks over HTTPS
1. Install n8n via npx


To install and run n8n locally, simply use the following command:


npx n8n

This command:

  1. Downloads the n8n package
  2. Installs the necessary dependencies
  3. Launches the n8n editor at

    Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

Setup Screenshots



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



2. Create Your Telegram Bot

  1. Open the BotFather in Telegram.
  2. Send the command /newbot and follow the instructions:
  • Choose a display Name
  • Set a Username (must end with bot, e.g., MyAIHelperBot)
    1. Copy the Bot Token provided after creation.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



3. Configure the Telegram Trigger in n8n

  1. In the n8n editor, drag in a Telegram Trigger node.
  2. Authenticate using your Bot Token.
  3. Optionally specify filters such as chat IDs.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



4. Build the AI Agent Workflow

a. Connect to an AI Model


Use one of the following nodes to process user messages with AI:

  • OpenAI Node: For GPT-3.5/GPT-4
  • Google Vertex AI Node: For models hosted by Google

Configure the node with your API key and set the model to use (e.g., gpt-3.5-turbo).


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



b. (Optional) Store Chat History


To support context or logs, add a Database or Google Sheet node to save messages and responses.

c. Send AI Responses Back to Telegram


Use the Telegram Send Message node and link it to the output of the AI node.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



5. Test the Bot Locally Using ngrok

  1. Save and Activate the workflow in n8n.
  2. ngrok automatically starts when you run it for the first time using the n8n start command. Copy the HTTPS URL generated by ngrok.
  3. Set this HTTPS URL as the Webhook URL in n8n’s settings.
  4. Send a message to your bot in Telegram.
  5. View the live execution logs in n8n to confirm the workflow is triggered and a response is sent.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Final Architecture Overview


Here's a visual overview of how all components—Telegram, n8n, and the AI model—interact in this workflow:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Conclusion


With just a few tools and no coding, you've built an intelligent, conversational Telegram bot powered by AI and managed entirely within your own infrastructure. Whether you're prototyping or building a production bot, n8n makes it easy and flexible.

Happy automating! ?


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу