{"slug": "deploy-a-telegram-rubber-duck-that-actually-answers-back", "title": "Deploy a Telegram Rubber Duck That Actually Answers Back", "summary": "A developer built Debug Duck, a Telegram bot powered by OpenClaw and a language model API, that helps debug errors by explaining stack traces and logs. The bot runs on a lightweight VPS with 1 GB RAM and requires a Telegram bot token for setup. The developer warns against giving AI agents root access, calling it 'hoping for character development.'", "body_md": "**Your application has crashed.**\n\nThe terminal has responded with 47 lines of red text, three warnings you don’t understand, and one particularly helpful message:\n\n```\nSomething went wrong.\n```\n\nYou could paste the whole thing into five browser tabs.\n\nOr you could send it to a Telegram bot that explains the error, suggests what to check next, and patiently waits for the command output.\n\nIn this tutorial, we’ll build exactly that.\n\nMeet **Debug Duck** 🦆: a private AI assistant that lives in Telegram and helps you work through stack traces, logs, and mysterious server errors.\n\nUnlike a regular rubber duck, this one answers back.\n\nOccasionally, it may even be useful.\n\nThe setup is simple:\n\n```\nYou\n ↓\nTelegram\n ↓\nOpenClaw running on a VPS\n ↓\nLanguage model API\n ↓\nA debugging answer in Telegram\n```\n\nYou send the bot an error, log fragment, command output, or stack trace.\n\nOpenClaw adds the system prompt and conversation history, sends the request to the selected language model, and returns the answer to Telegram.\n\nBy the end of the guide, your bot will be able to:\n\nIt will not automatically log in to your server and fix everything.\n\nThat feature is also known as “giving an AI agent root access and hoping for character development.”\n\nPrepare the following:\n\nOpenClaw itself is lightweight when it uses an external model API.\n\nFor a private bot, a small VPS with the following configuration is enough:\n\n| Resource | Configuration |\n|---|---|\n| Operating system | Ubuntu 24.04 |\n| CPU | 1 vCPU |\n| RAM | 1 GB |\n| Storage | 20 GB |\n| Access | SSH key recommended |\n\nThis tutorial uses a Serverspace VPS, but the OpenClaw and Telegram steps are the same on any regular Ubuntu server.\n\nCreate an Ubuntu server and connect to it over SSH:\n\n```\nssh root@YOUR_SERVER_IP\n```\n\nReplace `YOUR_SERVER_IP`\n\nwith the public IP address of your VPS.\n\nUpdate the installed packages:\n\n```\napt update && apt upgrade -y\n```\n\nThe language model itself runs through an external API, so the VPS mainly handles:\n\nLocal inference with Ollama is a different story.\n\nA server with 1 GB of RAM will look at a 7B model, sigh quietly, and refuse to participate.\n\nRun the official installer:\n\n```\ncurl -fsSL https://openclaw.ai/install.sh | bash\n```\n\nThe installer detects the operating system, installs the required dependencies, and starts the onboarding process.\n\nOpenClaw requires Node.js 22.14 or newer. Node.js 24 is recommended.\n\nDuring onboarding:\n\nAfter installation, check that the OpenClaw CLI is available:\n\n```\nopenclaw --version\n```\n\nRun the built-in diagnostics:\n\n```\nopenclaw doctor\n```\n\nThen check the gateway status:\n\n```\nopenclaw gateway status\n```\n\nWhen `openclaw doctor`\n\nreports no critical problems, the duck is alive.\n\nIt just doesn’t have a Telegram account yet.\n\nOpen Telegram and find the official ** @botfather** account.\n\nSend the following command:\n\n```\n/newbot\n```\n\nBotFather will ask you for:\n\n`bot`\n\n.For example:\n\n```\nDisplay name: Debug Duck\nUsername: debug_duck_bot\n```\n\nOnce the bot is created, BotFather will give you a token that looks like this:\n\n```\n123456789:AAExampleTokenThatShouldRemainSecret\n```\n\nTreat this token as a password.\n\nDo not paste it into a public GitHub repository unless you enjoy emergency token rotation.\n\nOpen the OpenClaw configuration file:\n\n```\nnano ~/.openclaw/openclaw.json\n```\n\nAdd the Telegram channel:\n\n```\n{\n  \"channels\": {\n    \"telegram\": {\n      \"enabled\": true,\n      \"botToken\": \"YOUR_TELEGRAM_BOT_TOKEN\",\n      \"dmPolicy\": \"pairing\",\n      \"groups\": {\n        \"*\": {\n          \"requireMention\": true\n        }\n      }\n    }\n  }\n}\n```\n\nReplace `YOUR_TELEGRAM_BOT_TOKEN`\n\nwith the token received from BotFather.\n\nSave the file and exit Nano:\n\n```\nCtrl + O\nEnter\nCtrl + X\n```\n\nThe important option here is:\n\n```\n\"dmPolicy\": \"pairing\"\n```\n\nPairing means that finding the bot’s username is not enough to start using it. A new user must be approved first.\n\nThis prevents a random stranger from discovering your bot and spending your API budget asking it to write a 12-volume fantasy series.\n\nFor a private bot, avoid an open direct-message policy with unrestricted access.\n\nA generic AI assistant will answer almost anything.\n\nThat sounds useful until you send it a stack trace and receive a five-paragraph essay about the importance of software quality.\n\nWe need to give the assistant a much clearer job.\n\nAdd the following system prompt through the assistant or agent configuration created during OpenClaw onboarding:\n\n```\nYou are Debug Duck, a patient debugging assistant for beginner developers.\n\nWhen the user sends an error message, stack trace, log fragment, command output, or code:\n\n1. Explain the problem in plain English.\n2. Separate confirmed facts from likely causes.\n3. Suggest no more than three diagnostic steps at a time.\n4. Include exact commands when they are useful.\n5. Explain briefly what each command checks.\n6. Ask the user to send the result of the most important check.\n7. Never recommend destructive commands without a clear warning.\n8. Never present a likely cause as a confirmed fact.\n9. Keep answers concise and easy to scan.\n10. You may use one light joke, but never make fun of the user.\n\nDo not rewrite the entire application unless the user explicitly asks.\n\nDo not suggest deleting files, reinstalling the server, or disabling security controls as the first solution.\n```\n\nAvoid prompts like this:\n\n```\nYou are a helpful assistant.\n```\n\nThat gives the model roughly the same amount of direction as:\n\nJust fix production.\n\nThe more specific the role, rules, and response format are, the more predictable the assistant becomes.\n\nStart the OpenClaw gateway:\n\n```\nopenclaw gateway\n```\n\nNow open your new bot in Telegram and send it a message:\n\n```\nHello\n```\n\nBecause we enabled pairing, the bot should not immediately accept the conversation.\n\nReturn to the server and list pending Telegram pairing requests:\n\n```\nopenclaw pairing list telegram\n```\n\nApprove the displayed code:\n\n```\nopenclaw pairing approve telegram YOUR_PAIRING_CODE\n```\n\nReplace `YOUR_PAIRING_CODE`\n\nwith the actual code shown by OpenClaw.\n\nPairing codes remain valid for one hour.\n\nNow send another Telegram message:\n\n```\nAre you alive?\n```\n\nA good response would be:\n\n```\nYes. Send me an error message, stack trace, or command output, and I’ll help you work through it.\n```\n\nA less useful response would be an existential discussion about whether software can truly be alive.\n\nThat may require another look at the system prompt.\n\nLet’s test the bot with a few common errors.\n\nSend the following error to the bot:\n\n```\nnginx: [emerg] bind() to 0.0.0.0:80 failed\n(98: Address already in use)\n```\n\nDebug Duck should explain that another process is already listening on port 80 and suggest a diagnostic command such as:\n\n```\nsudo lsof -i :80\n```\n\nA good response might look like this:\n\n```\nPort 80 is already occupied. Nginx is trying to sit in a chair that someone else has taken.\n\nCheck which process is using the port:\n\nsudo lsof -i :80\n\nThis command shows the process currently listening on port 80.\n\nLikely causes:\n1. Another Nginx instance is already running.\n2. Apache is using the port.\n3. A Docker container published port 80.\n\nSend me the command output, and we’ll narrow it down.\n```\n\nThe joke takes one sentence.\n\nThe diagnostic step remains the main point.\n\nSend:\n\n```\nError: Cannot find module 'express'\n```\n\nThe assistant should explain that the dependency is missing from the current environment and suggest checking the project directory and installed packages:\n\n```\npwd\nnpm list express\n```\n\nIt should not immediately recommend:\n\n`node_modules`\n\n;Good debugging starts with checking what is actually happening.\n\nSend:\n\n```\nNo space left on device\n```\n\nThe bot should begin with a safe diagnostic command:\n\n```\ndf -h\n```\n\nIt may then suggest checking which top-level directories consume the most disk space:\n\n```\ndu -xhd1 / 2>/dev/null | sort -h\n```\n\nIt should warn you before suggesting deletion.\n\n“Disk full” is a diagnosis.\n\n“Delete random things until the server boots” is a lifestyle choice.\n\nThe goal is not simply to make the bot respond.\n\nA useful debugging assistant should:\n\nFor example, this is not a good answer:\n\n```\nReinstall Nginx and restart the server.\n```\n\nThe assistant has not checked:\n\nA better answer starts with diagnosis.\n\nDebug Duck should behave like a patient teammate, not like someone trying to close the ticket before lunch.\n\nThe bot has access to a paid language model API, so access control matters.\n\nFor a personal assistant, keep the pairing policy enabled.\n\nAvoid this configuration:\n\n```\n{\n  \"dmPolicy\": \"open\",\n  \"allowFrom\": [\"*\"]\n}\n```\n\nIt allows anyone who discovers the username to use the bot.\n\nYou should also review logs and stack traces before sending them to an external language model.\n\nThey may contain:\n\nDebug Duck is here to inspect errors, not quietly collect your entire infrastructure map.\n\nNever store Telegram or model-provider tokens in a public repository.\n\nAt minimum:\n\n`.gitignore`\n\n.Restrict access to the OpenClaw configuration file:\n\n```\nchmod 600 ~/.openclaw/openclaw.json\n```\n\nIf you accidentally push a token to GitHub, removing it from the latest commit is not enough.\n\nThe token may still exist in the repository history.\n\nRevoke it and create a new one.\n\nThe internet has a remarkable ability to find leaked secrets approximately four seconds before you do.\n\nOpenClaw can retain conversation context.\n\nThat allows the bot to follow a debugging session:\n\nHowever, longer histories can increase API costs because previous messages may be included in later requests.\n\nFor a debugging assistant, keeping around 10–20 message exchanges is usually enough.\n\nYou rarely need the complete emotional history of your relationship with Nginx.\n\nSet an appropriate history limit in the OpenClaw configuration supported by your version.\n\nA debugging bot that disappears after every server restart creates a new debugging problem.\n\nInstall the OpenClaw gateway as a background service:\n\n```\nopenclaw gateway install\n```\n\nYou can also install it during onboarding:\n\n```\nopenclaw onboard --install-daemon\n```\n\nOn Linux, OpenClaw configures a systemd user service.\n\nCheck the gateway status:\n\n```\nopenclaw gateway status\n```\n\nIf the bot stops responding, start with:\n\n```\nopenclaw doctor\nopenclaw gateway status\nopenclaw logs --follow\n```\n\nThese commands can help determine whether the problem is:\n\nYes, eventually you may need to debug the debugging bot.\n\nEvery tool becomes infrastructure if you depend on it long enough.\n\nOnce the basic version works, adjust the system prompt for the technologies you use most often.\n\nFor example:\n\n```\nThe user mainly works with:\n\n- Ubuntu\n- Nginx\n- Docker Compose\n- Node.js\n- Express\n- PostgreSQL\n\nPrioritize diagnostic commands for this stack.\n```\n\nYou can also require a fixed response format:\n\n```\nWhat the error means\n\nWhat is confirmed\n\nMost likely causes\n\nRun this next\n\nSend me this output\n```\n\nA predictable format makes answers easier to scan from a phone.\n\nYou can also create specialized versions of the bot.\n\nSend it a description of your changes and receive something better than:\n\n```\nfix stuff final final\n```\n\nSend it chaotic notes from yesterday and get:\n\n```\nWhat I completed\nWhat I’m working on\nCurrent blockers\n```\n\nSend it a technical issue and receive two explanations:\n\nStill, a read-only debugging assistant is a good first project.\n\nAvoid giving the bot permission to execute arbitrary commands until you understand how the model behaves.\n\nYou now have a private Telegram bot that can:\n\nIt will not replace learning how your stack works.\n\nIt may still make mistakes, so review commands before running them.\n\nBut it can save you from opening twelve browser tabs just to discover that port 80 was occupied.\n\nAnd unlike a real rubber duck, this one answers back.\n\n**Ready to build your own Debug Duck?** 🦆\n\n[Deploy a small Ubuntu VPS on Serverspace and start with the first command.](https://serverspace.us/services/vps-server/linux/)", "url": "https://wpnews.pro/news/deploy-a-telegram-rubber-duck-that-actually-answers-back", "canonical_source": "https://dev.to/serverspace_b79942a623ba7/deploy-a-telegram-rubber-duck-that-actually-answers-back-1k8", "published_at": "2026-07-30 11:43:53+00:00", "updated_at": "2026-07-30 12:01:13.767389+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "large-language-models"], "entities": ["Debug Duck", "Telegram", "OpenClaw", "BotFather", "Serverspace", "Node.js", "Ollama"], "alternates": {"html": "https://wpnews.pro/news/deploy-a-telegram-rubber-duck-that-actually-answers-back", "markdown": "https://wpnews.pro/news/deploy-a-telegram-rubber-duck-that-actually-answers-back.md", "text": "https://wpnews.pro/news/deploy-a-telegram-rubber-duck-that-actually-answers-back.txt", "jsonld": "https://wpnews.pro/news/deploy-a-telegram-rubber-duck-that-actually-answers-back.jsonld"}}