Telegram to Home Assistant, control your smart home by chat
Opening Home Assistant, finding the right dashboard, tapping the right toggle, then doing it again for the next thing gets old fast. And when you’re carrying groceries or half-asleep, it’s honestly worse.
Smart home tinkerers feel this daily. Property managers and small office owners run into it too, because “just turn off the lights” becomes a mini project. This Telegram Home Assistant automation lets you run your home with one chat thread, including voice notes.
You’ll see what the workflow does end-to-end, what you need to connect, and where the real time savings show up once it’s running.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: Telegram to Home Assistant, control your smart home by chat
flowchart LR
subgraph sg0["Telegram Flow"]
direction LR
n0["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Telegram Trigger"]
n1["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Telegram Send"]
n2@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Reply Router", pos: "b", h: 48 }
n3["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Telegram Message Beautifier"]
n4["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/webhook.dark.svg' width='40' height='40' /></div><br/>Respond to Webhook"]
n5@{ icon: "mdi:swap-vertical", form: "rounded", label: "Transcription to ChatInput", pos: "b", h: 48 }
n6["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Get Voice File"]
n7@{ icon: "mdi:swap-vertical", form: "rounded", label: "Voice or Text", pos: "b", h: 48 }
n8@{ icon: "mdi:robot", form: "rounded", label: "Speech to Text", pos: "b", h: 48 }
n9@{ icon: "mdi:swap-horizontal", form: "rounded", label: "If", pos: "b", h: 48 }
n10["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Process messages"]
n11["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/telegram.svg' width='40' height='40' /></div><br/>Bot Is typing"]
n12@{ icon: "mdi:memory", form: "rounded", label: "Simple Memory1", pos: "b", h: 48 }
n13@{ icon: "mdi:wrench", form: "rounded", label: "Home assistant Connector", pos: "b", h: 48 }
n14@{ icon: "mdi:robot", form: "rounded", label: "Home Agent", pos: "b", h: 48 }
n15@{ icon: "mdi:memory", form: "rounded", label: "Simple Memory", pos: "b", h: 48 }
n16@{ icon: "mdi:brain", form: "rounded", label: "Google Gemini Chat Model", pos: "b", h: 48 }
n17@{ icon: "mdi:play-circle", form: "rounded", label: "When chat message received", pos: "b", h: 48 }
n9 --> n6
n9 --> n10
n14 --> n2
n2 --> n3
n2 --> n4
n15 -.-> n14
n7 --> n9
n6 --> n8
n12 -.-> n17
n8 --> n5
n10 --> n14
n0 --> n7
n0 --> n11
n16 -.-> n14
n13 -.-> n14
n5 --> n10
n17 --> n10
n3 --> n1
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n0,n17 trigger
class n8,n14 ai
class n16 aiModel
class n13 ai
class n12,n15 ai
class n2,n9 decision
class n4 api
class n3,n10 code
classDef customIcon fill:none,stroke:none
class n0,n1,n3,n4,n6,n10,n11 customIcon
The Problem: Smart Home Control Still Friction-Filled
Smart homes are supposed to remove little annoyances. In practice, you end up app-switching: Telegram for family messages, Home Assistant for devices, maybe another app for a speaker, then back again. The friction isn’t just time. It’s mental overhead, especially when commands are simple but frequent (“lights,” “thermostat,” “goodnight,” “who left the garage open?”). Miss one step, pick the wrong entity, or get stuck in the wrong dashboard, and suddenly you’re troubleshooting instead of living in the house.
The friction compounds. Here’s where it breaks down.
- You end up repeating the same actions across multiple rooms, which turns a 10-second idea into a 2-minute detour.
- Voice assistants can be unreliable, and when they fail you still need the app as a backup.
- Guests or team members don’t know your dashboards, so they ask you to do it anyway.
- There’s no clean “confirmation trail,” so you’re never fully sure what actually happened.
The Solution: Telegram Chat Commands That Run Home Assistant
This n8n workflow creates a conversational bridge between Telegram (and n8n’s built-in chat) and Home Assistant. You send a text command like “turn on living room lights,” or you drop a voice note like “goodnight mode,” and the workflow does the busywork: it figures out intent, converts speech to text when needed, and triggers the right Home Assistant action through an MCP tool connector. It also keeps short-term context, so you can follow up naturally (“make it warmer” after asking for the bedroom temperature). Finally, it routes a clean confirmation back to the right place, with Telegram formatting that’s actually readable.
The workflow starts with an incoming message from Telegram or the n8n chat UI. If it’s a voice note, it downloads the audio and transcribes it with OpenAI Whisper. Then a Gemini-powered agent interprets what you want and calls Home Assistant to execute the action, before sending a confirmation back to the same channel you used.
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say you trigger smart home actions about 10 times a day (lights, thermostat, a scene, and a quick status check). Manually, that’s often about 30 seconds to unlock, open Home Assistant, and find the right control, so you lose roughly 5 minutes daily. With this workflow, you send a Telegram message in about 10 seconds, and voice notes take maybe another minute for transcription and processing while you do something else. Over a week, that’s around 30 minutes back, plus fewer mistakes.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Telegram Bot for receiving and replying to messages
- Home Assistant to execute device actions and queries
- OpenAI API key (get it from your OpenAI API dashboard)
Skill level: Intermediate. You’ll paste API keys, connect Telegram, and map a few fields, but you won’t be writing an application.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
A message arrives in Telegram (or n8n chat). The workflow triggers on a new Telegram message or a message in n8n’s chat UI. It immediately sends a “typing…” action in Telegram so it feels responsive.
Voice notes get turned into text. If the incoming message is audio, n8n fetches the voice file from Telegram, transcribes it with OpenAI Whisper, then maps that transcript into the same input field used by normal text messages.
The assistant interprets intent and keeps context. Incoming text is normalized into a consistent structure (who sent it, where it came from, session ID). A Gemini chat model powers the “Smart Home Agent,” and short memory buffers keep the conversation coherent for follow-ups.
Home Assistant executes the action, then you get a confirmation. The agent calls the Home Assistant MCP tool to do the real work (turn on/off, adjust lights, broadcast a message, fetch a sensor value). A routing check sends the final response back to Telegram (beautified formatting) or back to the n8n chat webhook reply.
You can easily modify the recognized commands and response style to match your home setup and tone. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Telegram Trigger
This workflow starts by listening for incoming Telegram messages, then immediately branches to typing feedback and message normalization.
- Add and open Telegram Inbound Trigger.
- Set Updates to
message. - Credential Required: Connect your
telegramApicredentials. - Confirm that Telegram Inbound Trigger outputs to both Normalize Voice Or Text and Telegram Typing Action in parallel.
Step 2: Configure the Chat UI Message Trigger
This trigger enables direct web chat input to the assistant, feeding the same normalization path as Telegram.
- Add and open Chat UI Message Trigger.
- Set Public to
true. - In Options, set Load Previous Session to
memory. - Ensure Chat UI Message Trigger connects to Normalize Incoming Messages.
Step 3: Set Up Voice/Text Normalization and Transcription
This section handles voice input detection, voice file retrieval, transcription, and mapping transcript into the unified input field.
- In Normalize Voice Or Text, set text to
{{ $json?.message?.text || "" }}. - In Text Presence Check, set the condition to check if leftValue
{{ $json.message.text }}is empty. - In Fetch Voice File, set Resource to
fileand File ID to{{ $json.message.voice.file_id }}. - Credential Required: Connect your
telegramApicredentials in Fetch Voice File. - In Transcribe Audio, set Resource to
audioand Operation totranscribe. - Credential Required: Connect your
openAiApicredentials in Transcribe Audio. - In Map Transcript to Input, set chatInput to
{{ $json.text }}. - Ensure Map Transcript to Input connects to Normalize Incoming Messages.
Step 4: Set Up AI Processing and Home Assistant Integration
Normalized inputs are passed into the smart agent, which uses Gemini and a Home Assistant MCP tool with memory buffers.
- In Normalize Incoming Messages, keep the provided JavaScript to produce inputText, source, and sessionId.
- In Smart Home Agent, set Text to
{{ $json.inputText }}and Prompt Type todefine. - Open Gemini Chat Model and connect it to Smart Home Agent as the language model.
- Credential Required: Connect your
googlePalmApicredentials in Gemini Chat Model. - In Home Assistant MCP Tool, set Endpoint URL to
http://0.0.0.0:8123/mcp_server/sseand Authentication tobearerAuth. - Credential Required: Connect your
httpBearerAuthcredentials in Home Assistant MCP Tool. - Keep Short Memory Buffer connected as the ai_memory source for Smart Home Agent.
- Keep Short Memory Buffer A connected as the ai_memory source for Chat UI Message Trigger.
Step 5: Configure Output Routing and Responses
The workflow branches response formatting based on the message source and sends replies to Telegram or a webhook response.
- In Response Route Check, set the condition to check leftValue
{{ $('Normalize Incoming Messages').item.json.source }}equalstelegram. - In Telegram Output Formatter, keep the JavaScript formatting and chunking logic as provided to format HTML output.
- In Telegram Reply Sender, set Text to
{{ $json.text }}and Chat ID to{{ $('Telegram Inbound Trigger').item.json.message.chat.id }}. - In Telegram Reply Sender, confirm Parse Mode is set to
HTML. - Credential Required: Connect your
telegramApicredentials in Telegram Reply Sender. - In Webhook Reply Output, set Respond With to
textand Response Body to{{ $json.output }}. - In Telegram Typing Action, set Operation to
sendChatActionand Chat ID to{{ $('Telegram Inbound Trigger').item.json.message.chat.id }}. - Credential Required: Connect your
telegramApicredentials in Telegram Typing Action.
Final Step: Test and Activate Your Workflow
Verify both Telegram and Chat UI inputs, then activate the workflow for production use.
- Click Execute Workflow to run a manual test.
- Send a Telegram text and a Telegram voice message to ensure both the text path and transcription path reach Normalize Incoming Messages.
- Send a message via the Chat UI and confirm it routes through Normalize Incoming Messages and Smart Home Agent.
- Check that Telegram replies are formatted and delivered through Telegram Reply Sender, and non-Telegram responses go through Webhook Reply Output.
- When satisfied, toggle the workflow to Active to enable production execution.
Common Gotchas
- Telegram bot permissions can be the silent blocker. If replies stop working, check the bot token in n8n and confirm the chat ID is correct for the conversation you’re testing.
- If you’re using Wait nodes or external rendering, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses.
- Default prompts in AI nodes are generic. Add your brand voice early or you’ll be editing outputs forever.
Frequently Asked Questions
About 30 minutes if your Telegram bot and Home Assistant are already working.
No. You’ll mostly connect accounts, paste API keys, and adjust a few message-mapping fields in n8n.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in OpenAI Whisper costs (usually a few cents for short voice notes) and any Gemini usage on your Google AI plan.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, and you should. You can expand the Smart Home Agent’s instructions to include your room names and scene names, then let the Home Assistant MCP tool handle the actual calls. Common customizations include adding a “goodnight” routine, limiting control to a whitelist of entities, and changing the Telegram message beautifier so confirmations match your preferred format.
Usually it’s an invalid or rotated bot token in n8n. Update the Telegram credentials, then confirm you’re messaging the correct bot and testing in the chat you expect. If voice notes are failing specifically, also check that the workflow can fetch the voice file from Telegram and that your OpenAI API key still has access to the transcription endpoint.
A lot for a typical home. On n8n Cloud Starter, you’re limited by monthly executions, while self-hosting mainly depends on your server. In practice, this workflow handles normal household traffic easily, and the only real bottleneck is how fast your AI transcription/model responses return.
For conversational smart home control, usually yes. n8n handles branching, memory, and agent-style logic cleanly, and you can self-host for unlimited executions, which matters once you start using it daily. Zapier and Make are fine for simple “when X then Y,” but they get awkward when you want follow-up questions, voice transcription, and tool-calling in the same flow. Also, Home Assistant integrations tend to be more flexible when you can call what you need rather than hoping a prebuilt action exists. If you want a second opinion, Talk to an automation expert and we’ll help you pick the simplest option that still works.
Once this is set up, smart home control becomes a quick message, not a mini mission. The workflow handles the repetitive stuff. You handle the rest.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.