Telegram bot that proofreads your English text using a local LLaMA model (via an HTTP API such as Ollama) and sends back corrected text plus a short explanation of the changes.
Author: Yaroslav Slipchuk LinkedIn
- Node.js: v18+ recommended.
- Telegram account to create a bot via BotFather.
- Local LLaMA server:
- Easiest option: install Ollama and pull a LLaMA model, for example:
ollama pull llama3- This will expose an HTTP API at
http://localhost:11434by default.
- Easiest option: install Ollama and pull a LLaMA model, for example:
- Open Telegram and start a chat with
@BotFather. - Send
/newbotand follow the prompts. - Copy the bot token you receive; you will need it as
TELEGRAM_BOT_TOKEN.
From the project root:
npm installCreate a .env file in the project root with at least:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
# Base URL for your local LLaMA server (Ollama by default)
LLAMA_BASE_URL=http://localhost:11434
# Model name as known by your local LLaMA server
# For Ollama typical options: llama3, llama3.1, llama3.2, etc.
LLAMA_MODEL=llama3
# Lower = more deterministic, higher = more creative
LLAMA_TEMPERATURE=0.2Adjust these values as needed (for example, if your LLaMA server runs on a different port or with another model name).
- Install Ollama from their website (
https://ollama.com). - Pull a LLaMA model:
ollama pull llama3- Ensure the Ollama service is running. On most systems it starts automatically and listens on
http://localhost:11434.
Development mode (TypeScript directly):
npm run devOr build and run:
npm run build
npm startYou should see a log line:
Telegram proofreading bot is running.
Now open Telegram, find your bot (the username you set in BotFather), and start chatting.
- Send any English text to the bot.
- The bot calls the local LLaMA model with a system prompt that asks for:
- A corrected version of your text, and
- A short explanation of the main changes.
- The reply includes:
- A code block with the corrected text.
- An explanation section underneath.
- The bot calls the local LLaMA model with a system prompt that asks for:
- Alternatively, reply to a specific message with
/proofto proofread only that message.
- The code assumes a chat-style HTTP API similar to Ollama:
POST /api/chatonLLAMA_BASE_URL.- Request body includes:
model: the model name (e.g.llama3).messages: array withsystemandusermessages.temperature: controlled byLLAMA_TEMPERATURE.
- The model is instructed to respond with pure JSON:
{
"corrected": "corrected full text here",
"explanation": "short bullet-style explanation of the main changes"
}- If parsing fails, the bot falls back to returning the raw text from the model as the corrected version.
- Prompting / style: update the system prompt in
src/llamaClient.ts. - Bot UX: customize commands and messages in
src/bot.ts. - Model / server: change default values in
src/config/env.tsor via your.envfile.
