Skip to content

Your Own AI Sidekick: Build a Personal Assistant Bot with n8n and Telegram

Your Own AI Sidekick: Build a Personal Assistant Bot with n8n and Telegram

This page may contain affiliate links.

\n

Imagine having a tireless, customisable assistant at your beck and call, right inside your favourite messaging app. An assistant that helps you manage your day, track your side hustle projects, or even answer quick questions without you ever leaving Telegram. Sounds like something out of a sci-fi film? Not anymore. With the power of n8n and Telegram, you can build your very own personal assistant bot, tailored precisely to your needs, and all without writing reams of complex code.

\n

Whether you're looking to automate tedious daily tasks, streamline your burgeoning digital side hustle, or just want to dip your toes into the exciting world of AI and automation, this guide is for you. We'll walk through everything from setting up the basics to integrating advanced AI features, making your personal assistant not just smart, but genuinely useful.

\n\n

The Foundations: What You'll Need

\n

Before we dive into the nitty-gritty, let's gather our essential tools. The beauty of this setup is its accessibility and, in many cases, its affordability.

\n\n

1. n8n: Your Automation Engine

\n

n8n (pronounced 'nation') is a powerful, open-source workflow automation tool. Think of it as your digital brain, connecting all your apps and services. You have a few options for getting started:

\n

  • \n
  • Self-Hosted (Free): This is the most flexible and cost-effective option, perfect for side hustlers. You can run n8n on your own server, a Raspberry Pi, or a cloud VPS like DigitalOcean or AWS. It requires a bit of technical know-how but gives you full control. For a simple setup, Docker is your friend.
  • \n
  • n8n Cloud (Paid): If you prefer a hands-off approach, n8n offers a cloud service. Plans start from around £17 per month for basic usage, scaling up with more executions. Great for those who want to jump straight into building without server management.
  • \n

\n\n

2. Telegram Account & BotFather

\n

Telegram is our communication interface. It's fast, secure, and has an excellent API for bots. You'll need a personal Telegram account to get started.

\n

  • \n
  • Creating Your Bot: Head over to Telegram and search for @BotFather. This official bot helps you create and manage your own bots.
  • \n
  • Follow these steps with BotFather:\n\n
    1. \n
    2. Type /newbot and press Enter.
    3. \n
    4. Give your bot a friendly name (e.g., "Sheddad Assistant").
    5. \n
    6. Give your bot a unique username, which must end in 'bot' (e.g., "SheddadAssistantBot").
    7. \n
    8. BotFather will then provide you with an HTTP API Token. This is crucial! Copy it somewhere safe; we'll need it shortly.
    9. \n
  • \n

\n\n

\n

To make your assistant truly smart, you'll want to integrate with other services. Examples include:

\n

  • \n
  • OpenWeatherMap: For weather forecasts. Grab a free API key from their website.
  • \n
  • OpenAI: For advanced conversational AI. You'll need an API key from their platform. Costs are typically pennies per request for casual use (e.g., GPT-3.5-turbo).
  • \n
  • Google Sheets, Notion, Trello, etc.: For note-taking, task management, or data storage.
  • \n

\n\n

Setting Up Your n8n & Telegram Connection

\n

Now, let's connect Telegram to n8n and build our first basic interaction.

\n\n

  1. \n
  2. \n
  3. \n
    • \n
    • Authentication: Click 'New Credential'. Give it a name (e.g., "My Telegram Bot API"). Paste the HTTP API Token you got from BotFather into the 'Bot Token' field. Save the credential.
    • \n
    • Mode: For a personal assistant, 'Webhook' is usually best as it provides instant responses.
    • \n
    • Test the Trigger: Click 'Execute Workflow' in the top right. Then, go to your Telegram bot and send it a message (e.g., "Hello"). You should see data appear in the Telegram Trigger node in n8n, confirming the connection.
    • \n
  4. \n
    • \n
    • Operation: Select 'Send Message'.
    • \n
    • Chat ID: This tells the bot who to reply to. You can get this dynamically from the trigger node's output. Click the cogwheel next to the Chat ID field, select 'Add Expression', and navigate to Trigger -> Output Data -> JSON -> message -> chat -> id.
    • \n
    • Text: Let's make a simple echo bot. Add an expression for the message text: Trigger -> Output Data -> JSON -> message -> text.
    • \n
    • Test: Click 'Execute Workflow' (if it's not already executing from the trigger test). Send another message to your bot on Telegram. It should now echo your message back to you!
    • \n
    • \n
    • Trigger: Telegram Trigger (listening for messages).
    • \n
    • Node 1 (IF): Add an 'IF' node. Condition: {{$json.message.text.startsWith('/note')}}. This checks if the message starts with '/note'.
    • \n
    • Node 2 (Code / Set): If true, use a 'Code' node or a 'Set' node to extract the note text. For example, in a Code node: items[0].json.note = $json.message.text.substring(6); (to remove "/note ").
    • \n
    • Node 3 (Google Sheets / Notion): Add a 'Google Sheets' or 'Notion' node. Authenticate it. Configure it to 'Append Row' (Google Sheets) or 'Create Database Item' (Notion), mapping your extracted note to the relevant column/property.
    • \n
    • Node 4 (Telegram Send Message): Send a confirmation back: "Note saved: {{$json.note}}".
    • \n
    • \n
    • Trigger: Telegram Trigger (listening for messages like '/weather London').
    • \n
    • Node 1 (IF): Condition: {{$json.message.text.startsWith('/weather')}}.
    • \n
    • Node 2 (Code / Set): Extract the city name. E.g., items[0].json.city = $json.message.text.substring(9);.
    • \n
    • Node 3 (HTTP Request): Add an 'HTTP Request' node.\n\n
      • \n
      • Method: GET
      • \n
      • URL: https://api.openweathermap.org/data/2.5/weather?q={{$json.city}},uk&appid=YOUR_OPENWEATHERMAP_API_KEY&units=metric (replace with your API key).
      • \n
    • \n
    • Node 4 (Telegram Send Message): Parse the JSON response from OpenWeatherMap and send a formatted message:
      "Weather in {{$json.city}}: {{$node["HTTP Request"].json.weather[0].description}}, Temperature: {{$node["HTTP Request"].json.main.temp}}°C. Feels like {{$node["HTTP Request"].json.main.feels_like}}°C."
    • \n
    • \n
    • Trigger: Telegram Trigger (e.g., for messages starting with '/ask').
    • \n
    • Node 1 (IF): Condition: {{$json.message.text.startsWith('/ask')}}.
    • \n
    • Node 2 (Code / Set): Extract the question.
    • \n
    • Node 3 (OpenAI): Add an 'OpenAI' node. Authenticate with your OpenAI API key.
      \n\n
      • \n
      • Model: gpt-3.5-turbo or gpt-4 (choose based on cost/performance).
      • \n
      • Operation: 'Chat Completion'.
      • \n
      • Messages: Configure a user message like: "Answer the following question succinctly: {{$json.question}}".
      • \n
    • \n
    • Node 4 (Telegram Send Message): Send the AI's response back to Telegram: {{$node["OpenAI"].json.choices[0].message.content}}.
    • \n

\n

Add a Telegram Send Message Node (Echo Bot)

\nLet's make our bot respond. Add another Telegram node, but this time select 'Telegram' (the regular operation node, not the trigger).\n\nCongratulations, you've built your first Telegram bot!\n\n

Supercharging Your Assistant: Practical Examples

\nAn echo bot is fun, but let's make it genuinely useful. Here are a few practical examples:\n\n

1. Quick Note Taker

\nImagine sending a quick thought to your bot and having it saved to a Google Sheet or Notion database.\n\n\n

2. Instant Weather Forecast

\nAsk your bot for the weather in any UK city.\n\n\nAt sheddad.tech, we're all about making complex tech accessible for your side hustle. If the thought of building these workflows from scratch feels a bit daunting, don't worry! We've done the heavy lifting for you. Our n8n Starter Workflows offer plug-and-play n8n workflow templates you can import in minutes (from £9). They're the perfect shortcut to getting powerful automations up and running, allowing you to focus on growing your business without getting bogged down in setup.\n\n

Taking It Further: Advanced Personalisation & AI Integration

\nOnce you're comfortable with the basics, the sky's the limit for your personal assistant.\n\n

1. AI-Powered Q&A with OpenAI

\nIntegrate an OpenAI node to let your bot answer general knowledge questions, summarise text, or even brainstorm ideas for your side hustle.\n\n\n

2. Conditional Logic and User Preferences

\nUse more 'IF' nodes to create complex decision trees. For example, if a user sends '/settings', your bot could offer options to set their default city for weather, or preferred reminder times. You could store these preferences in a simple Google Sheet or a database, retrieving them when needed.\n\n

3. Scheduling and Reminders

\nCombine your bot with a 'Cron' node (n8n's time-based scheduler) or integrate with a calendar API (like Google Calendar). Your bot could parse messages like '/remind me to call John tomorrow at 10am' and then schedule a Telegram message to yourself at the specified time.\n\n

4. Error Handling

\nAs your workflows get more complex, add 'Error Trigger' nodes and 'Try/Catch' nodes to gracefully handle issues. For instance, if an API call fails, your bot could send you an alert instead of just crashing silently.\n\n

Conclusion

\nBuilding a personal assistant bot with n8n and Telegram might seem like a big project, but as you've seen, it's highly modular and incredibly rewarding. You start with simple connections and gradually add layers of intelligence and functionality. This isn't just about automation; it's about reclaiming your time, boosting your productivity, and even adding a clever new tool to your side hustle toolkit.\nThe beauty of n8n lies in its flexibility. There are hundreds of integrations, limited only by your imagination. So, get experimenting, build the assistant that truly serves your unique needs, and let us know what amazing automations you create! Your smart, tireless AI sidekick is just a few nodes away.

\n

Add the Telegram Trigger Node

\nSearch for 'Telegram' and select the 'Telegram Trigger' node. This node listens for messages sent to your bot.\n\n

\n

Create a New Workflow in n8n

\nFrom the n8n dashboard, click 'New' to create a blank workflow.\n

\n

Start Your n8n Instance

\nIf self-hosting, ensure your n8n instance is running and accessible (e.g., via http://localhost:5678 or your domain). If using n8n Cloud, log in to your dashboard.\n

Written by

Richard Tucker

View all posts →