Installing and Configuring a Telegram Bot with OpenClaw
openclaw is A powerful AI-driven bot framework that supports integration with multiple models and platforms. This guide provides a detailed walkthrough on how to deploy OpenClaw on a Tencent Cloud Lighthouse server and integrate it with the Telegram platform, enabling you to build a reliable AI assistant service for your projects.
Environment Preparation
Server Requirements
Recommended Configuration: Tencent Cloud Lighthouse (minimum 2 vCPUs, 2 GB RAM)
Operating System: Ubuntu 20.04 LTS or newer
Network Environment: A server located outside mainland China (to ensure smooth access to GitHub and other international services)
Disk Space: At least 10 GB of free storage
Prerequisites
Ensure your server can:
Access GitHub without restrictions
Connect to the OpenRouter API
Communicate with the Telegram bot API
installation Steps
Step 1: Download and Run the Installation Script
Use the official installation script for quick deployment:
curl -fsSL https://openclaw.bot/install.sh | bash
Step 2: Accept the Disclaimer
After installation, the system will display a disclaimer. Carefully read it and type yes to proceed.
Step 3: Choose Installation Mode
We recommend selecting QuickStart mode for rapid setup.
Configuration Phase
Step 4: Configure the Model Provider
Select openrouter as your model provider and complete the following:
Enter your OpenRouter API Key: Obtain this key from your OpenRouter dashboard.
Choose a Model: We recommend
moonshotai/Kimi-k2.5—a well-balanced option in terms of performance and cost.
Step 5: Configure the Telegram Platform
Select Telegram as your target platform:
Enter Your Bot Token: Use the token issued by @BotFather when you created your Telegram bot.
Confirm Configuration: The system will validate your token automatically.
Step 6: Complete Remaining Settings
For all other options, we recommend accepting the default settings—the installer will handle them automatically.
Pairing & Authentication
Step 7: Establish Telegram Connection
Generate a Pairing Code: Send any message to your Telegram bot. The system will generate a unique pairing code.
Approve the Pairing on the Server: Run the following command on your server, replacing
[pairing-code]with the actual code:
openclaw pairing approve telegram [pairing-code]
Upon successful pairing, you’ll see a confirmation message indicating that the system is running properly.
Usage
Now you can start chatting with your AI bot directly in Telegram! Just send a message to your bot, and it will reply using the configured AI model.
Troubleshooting
Issue 1: Unable to Access GitHub
# Check network connectivity ping github.com # If needed, configure a proxy export https_proxy=http://your-proxy:port
Issue 2: API Key Validation Failed
Verify that your OpenRouter API key is correctly formatted.
Check your OpenRouter account balance and permissions.
Ensure the model name (e.g.,
moonshotai/kimi-k2.5) is spelled correctly.
Issue 3: Telegram Bot Fails to Connect
Confirm that your Bot Token is valid and hasn’t been revoked.
Make sure the bot has been started (send it a
/startcommand).Check your server’s firewall settings to ensure outbound HTTPS traffic (port 443) is allowed.
Viewing Logs
Check the service status and real-time logs:
openclaw status openclaw logs --follow
Performance Optimization Recommendations
Server Tuning
Memory: For high-concurrency scenarios, use at least 4 GB RAM.
Network: Consider using a CDN or proxy to accelerate API responses.
Storage: Use SSD storage to improve I/O performance.
Model Selection Guidance
Cost-sensitive: Use models like
moonshotai/kimi-k2.5(Chinese-developed, affordable).Performance-first: Opt for advanced models such as
GPT-5.2orclaude-4-5-Opus(if available via OpenRouter).
Monitoring & Maintenance
Daily Monitoring
System Resources: Regularly monitor CPU and memory usage.
API Health: Track OpenRouter API availability and latency.
Log Review: Periodically inspect error and access logs for anomalies.
Backup Strategy
Configuration Backup: Regularly back up your OpenClaw configuration files.
Data Backup: If storing conversation history or user data, implement a backup routine.
Conclusion
Congratulations! You’ve successfully deployed OpenClaw on your Tencent Cloud server and integrated it with Telegram. You can now:
Chat with your AI assistant directly in Telegram
Leverage multi-model support for flexible AI interactions
Extend and customize the open-source framework for your own needs
Next Steps & Extensions
Multi-Platform Support: Integrate with Discord, Slack, and more.
Custom Plugins: Develop your own modules for specialized functionality.
Group Management: Enable group chat support and role-based permissions.
Useful Resources
With these steps, you now have a robust, self-hosted AI bot service ready for production. If you encounter issues, consult the official documentation or join the community for support.
Comments & Questions (0)
No comments yet
Be the first to comment!