Templates / Answer Telegram customer messages with Ollama, OpenAI, or Anthropic

Answer Telegram customer messages with Ollama, OpenAI, or Anthropic

Ready for 3.0

by Tucker · 29 views · created 2026-09-29 · Support Chatbot, AI Chatbot

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

Nodes used (5)

Telegram

What it does

Quick overview This workflow replies to incoming Telegram bot messages using an Ollama, OpenAI, or Anthropic chat model constrained by your business notes, and falls back to a predefined message when it can’t answer or the AI call fails. How it works 1. Triggers when your Telegram bot receives a new message. 2. Loads recent conversation turns for the Telegram chat from n8n’s workflow static data to provide context. 3. Builds a provider-specific chat request (Ollama, OpenAI, or Anthropic) by injecting your business name, knowledge notes, conversation history, and the new message into a JSON-only prompt. 4. Sends the request to the selected AI endpoint via HTTP. 5. Parses the AI response as JSON and only uses the model’s reply when it marks the question as answerable, otherwise it uses your predefined fallback message. 6. Sends the chosen reply back to the customer in Telegram and appends both the customer and bot messages to the stored chat log. 7. If the AI request errors, sends the fallback message to Telegram so the customer still gets a response. Setup 1. Create a Telegram bot with BotFather and connect your Telegram credentials in the Telegram Trigger and Telegram send-message nodes. 2. In the Settings node, fill in businessname, knowledge (one fact per line), and optionally customize cannotanswermessage, aiprovider, and aimodel. 3. If using Ollama, ensure Ollama is running and reachable at ollamaurl and that the selected model is pulled locally. 4. If using OpenAI or Anthropic, configure header-based authentication on the HTTP Request node with your API key credential and set aiprovider and aimodel accordingly.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.