How I Built Content Posting Bots in Termux Using Just My Phone
# Automating My Workflow: How I Built Content Posting Bots in Termux Using Just My Phone
Have you ever wished your phone could automatically share your YouTube videos and blog posts to your Telegram channel, even while you sleep or work? In this blog, I’ll walk you through how I achieved exactly that—using only my Android phone, the Termux app, and a bit of coding. If you want to automate your content distribution with full control directly from your mobile, this guide is for you!
Why Automate Posting from Your Phone?
- *Instantly share new content with followers—no manual posting needed.*
- *Run everything directly on your Android device; no PC or paid service required.*
- *Learn practical scripting and bot-building skills on real-world projects.*
Tools and Platforms I Used
- Termux: A powerful terminal app for Android, enabling Linux-like scripting.
- Python: For scripting, automation, and API work.
- Telegram Bot:To post rich content to my channel.
- YouTube Data API v3: For reliable fetching of latest YouTube videos.
- Blogger RSS Feed: To track and post new blogs automatically.
Step 1: Setting Up the Bot Environment
1. Installed Termux:
Downloaded from F-Droid/Google Play to turn my Android into a mini server.
2. Installed Python and Required Packages:
```bash
pkg update && pkg install python
pip install requests feedparser
```
3. **Created a Telegram Bot:**
Used [@BotFather](https://core.telegram.org/bots#6-botfather) to get a bot token and made the bot an admin in my channel.
Step 2: Collecting All the Key Details
Step 3: Writing the Automation Script
The script would:
- Fetch the latest posts from Blogger and YouTube.
- Format the messages with titles, descriptions, and links for better engagement.
- Post them automatically to my Telegram channel.
- Remember which items it has already posted, so nothing is ever shared twice.
Core Script Features
- Reads YouTube and Blogger sources.
- Uses files to track already posted blog/video items.
- Formats posts with Markdown for rich preview in Telegram.
- Runs in a loop, checking every 10 minutes.
Example Code Snippet
```python
import requests, feedparser, time, os
TELEGRAM_BOT_TOKEN = "YOUR_TOKEN"
TELEGRAM_CHANNEL = "@yourchannel"
YOUTUBE_API_KEY = "YOUR_YT_API_KEY"
YOUTUBE_CHANNEL_IDS = ["UCxxxx...", "UCyyyy..."]
BLOGGER_RSS_URL = "https://yourblog.blogspot.com/feeds/posts/default?alt=rss"
def post_to_telegram(token, channel, text):
url = f"https://api.telegram.org/bot{token}/sendMessage"
payload = {"chat_id": channel, "text": text, "parse_mode": "Markdown"}
requests.post(url, data=payload)
# ...Script continues as in the explained steps above
```
Step 4: Keeping It Running—Even After Closing Termux
To make sure my automation never stops, I used:
- tmux: Installed and started a session using:
```bash
pkg install tmux
tmux
python autopost.py
```
Detached the session with `Ctrl+B` then `D`. The bot kept working in the background, even after closing Termux or locking my device.
Step 5: Editing and Saving Scripts in tmux
Editing code was as simple as:
- Opening nano/vim inside my tmux session:
```bash
nano autopost.py
```
- Saving with `Ctrl + O`, then exiting nano with `Ctrl + X`.
This meant I could tweak and improve the automation on-the-fly, even without leaving Termux.
Results: My Channel, Always Fresh and Updated
With this setup, my Telegram channel posts each new YouTube video and blog article automatically. I no longer worry about forgetting to share content or having to do it manually on a phone browser. Instead, Termux runs everything for me—hands-off, mobile, and efficient.
Pro Tips for Anyone Wanting to Try
- Always use real YouTube channel IDs (not handles) for both API and RSS.
- Keep your API keys and bot tokens safe—never share them publicly.
- Use markdown formatting in Telegram for attractive previews.
- With `tmux` or `screen`, your automations stay alive in the background.
- Store already-posted item IDs in a file for true persistency.
I hope this guide inspires you to build your own automation—right from your phone! If you have questions, need code samples, or want to expand automation to other platforms, drop a comment.
Check this my telegram channel - My telegram channel
Citations:
[1] 1000026753.jpg https://pplx-res.cloudinary.com/image/upload/v1752867530/user_uploads/82313908/0d87d7c5-630d-44ac-97cd-3fad2c206561/1000026753.jpg