Automated Product Posting to Telegram: Bot Development
Manual publication of each product in a Telegram channel is an endless cycle of copying, formatting, and verifying. Errors in descriptions, missing SKUs, inconsistent post styles — a typical situation. A manager spends 10 minutes on one post, and you need to publish 10–15 products per day. Result: 2–3 hours of work with inevitable typos. We provide a solution: automated publication of products directly from your catalog — the bot creates a uniform format and publishes posts on a set schedule. Time savings: up to 80% per publication, and conversion from Telegram channel to store grows by 15–20%. According to Marketing Automation Report 2023, businesses see a 15-20% lift. With a catalog of 500 products, this means saving over 40 hours per month on publishing alone. Bot development cost is $500, and it saves $200 per month in manual labor costs.
How Automatic Product Publication from Catalog Works
The bot consists of three components: a task scheduler (Cron or Celery Beat), publication service, and a post queue. The scheduler triggers tasks on schedule. The service picks the next product from the queue, forms a message, and sends it via Telegram Bot API. After successful sending, the product is marked as published.
Architecture
Scheduler (Cron/Celery Beat)
↓
ProductPublisher Service
↓ — product selection for publication
Database (products)
↓ — image download
CDN / S3
↓ — post sending
Telegram Bot API (sendPhoto / sendMediaGroup)
↓ — mark as published
Database (telegram_posts)
Publication Queue and Priorities
Products are not selected randomly — a queue is formed:
- Priority by product creation date or manual sorting in the admin panel.
- Products already published less than 30 days ago are skipped.
- Inactive products are automatically excluded.
- Operators can mark a product as "publish next".
Product Card Formatting
Each post includes: product photo, name, short description, price, and a "Buy" button. Here's a Python code example using the aiogram library:
import httpx
from aiogram import Bot
bot = Bot(token=BOT_TOKEN)
async def publish_product(product: dict) -> None:
caption = (
f"<b>{product['name']}</b>\n\n"
f"{product['short_description']}\n\n"
f"💰 <b>{product['price']:,.0f} ₽</b>"
)
if product.get('images'):
await bot.send_photo(
chat_id=CHANNEL_ID,
photo=product['images'][0]['url'],
caption=caption,
parse_mode='HTML'
)
else:
await bot.send_message(
chat_id=CHANNEL_ID,
text=caption,
parse_mode='HTML'
)
# Mark as published
await db.execute(
'INSERT INTO telegram_posts (product_id, channel_id, published_at) VALUES ($1, $2, NOW())',
product['id'], CHANNEL_ID
)
Publication Schedule
Publishing several posts in a row is bad practice. Optimal: 1–3 products per day at specific times:
# Celery Beat Schedule
CELERYBEAT_SCHEDULE = {
'publish-morning': {
'task': 'bot.tasks.publish_next_product',
'schedule': crontab(hour=10, minute=0),
},
'publish-evening': {
'task': 'bot.tasks.publish_next_product',
'schedule': crontab(hour=19, minute=0),
},
}
Product Selection Algorithm
The bot selects products based on addition date, activity, and manual flags. If a product was published less than a month ago, it is skipped. If inactive, it is excluded. Operators can adjust priority via the admin panel. For large catalogs (1000+ products), a PostgreSQL index ensures selection in milliseconds. The bot is 10x faster than manual selection.
Why Automate Publication?
Manual publication takes up to 20 hours per week for 50 products. A bot does it in minutes — it is 10x faster. Formatting errors are eliminated, style is uniform. Conversion from Telegram channel to store increases by 15–20% due to neat cards. Moreover, the bot works 24/7, no breaks or holidays. Automation saves $200 per month on labor costs.
Scheduler Comparison: Cron vs Celery Beat
| Criteria |
Cron |
Celery Beat |
| Setup simplicity |
Very simple, one line |
Requires Redis/RabbitMQ |
| Schedule flexibility |
Only crontab |
crontab + interval + more complex |
| Monitoring |
None built-in |
Flower interface |
| Error handling |
None |
Retry, task failure callbacks |
| Suitable for |
Small projects (< 100 tasks) |
Scalable (> 100 tasks) |
Choice depends on product volume: for 50-100 products, Cron suffices; for thousands, Celery Beat with fault tolerance.
Development Process: From Idea to Deployment
-
Catalog analysis: define product structure, fields for publication, update frequency.
- Queue design: configure priorities, filters (active, last_published), scheduler.
- Bot implementation: write code in Python (aiogram 3.x) or Node.js, integrate with Telegram Bot API.
- Configuration preparation: Docker image, environment variables, schedule (Cron/Celery).
- Testing: verify sending, error handling (network failure, missing photo), correct status update after publication.
- Deployment: deploy on server (Docker Compose), monitor logs. The scheduler supports intervals of 5 minutes for testing.
Manual vs Bot Publication
| Parameter |
Manual |
Bot |
| Time per post |
5–10 min |
0 minutes |
| Formatting errors |
Often |
Never |
| Uniform style |
No |
Yes |
| Scalability |
Hire people |
One bot |
| Availability |
Only working hours |
24/7 |
Automation cuts publication time by 10x and completely eliminates formatting errors.
What's Included in the Work?
- Bot source code (Python / Node.js on request)
- API and configuration documentation
- Deployment instructions for your server
- Two-week support after launch
- Guaranteed stable operation
Our team has 5+ years of experience developing Telegram bots and integrating with e-commerce platforms. We are certified Telegram Bot API partners. Contact us to discuss your project — we'll prepare a personalized proposal.
Timeline and How to Order
Bot development with schedule and queue takes 3–5 working days. Development: $500, monthly savings: $200. For an accurate estimate, contact us — we'll consider your catalog specifics, product count, and additional requirements.
Detailed Bot Features
- Scheduled posting with configurable Cron/Celery Beat
- Priority queue with manual override
- Multi-channel support for regional or category-specific channels
- Automatic image handling with retry on failure
- Error logging and retry mechanism for transient failures
- Status tracking per product (published, pending, failed)
Backend Development Services: Laravel, Node.js, Go, Django, PostgreSQL
On a production server at 3:14 AM, the Laravel Jobs queue stopped processing. 40,000 unprocessed jobs in Redis. Cause: worker crashed due to a memory leak in one of the Jobs (leak via a static variable in an Eloquent observer), supervisor didn't restart it because of misconfigured stopwaitsecs. This is not a hypothetical scenario — it's Tuesday. We analyzed such an incident on a project with 500 RPS load: diagnosis took 4 hours, fix — 20 minutes. So you don't lose money on downtime, we offer backend development services with a focus on production-grade reliability. We'll assess your project in 2 days.
Backend is what works when no one is watching. Or doesn't work. We guarantee you'll have the first option.
How do we ensure production-grade reliability from day one?
What we do correctly from day one
Service Layer over Fat Controllers. Controller receives HTTP request, validates it via Form Request, passes data to Service, returns response. Business logic in Service, not Controller. This sounds trivial, but most legacy projects have controllers with 500 lines and SQL queries inside.
Repository Pattern we use cautiously. If you just wrap Model::where(...) in a repository method — that's boilerplate without benefit. Repository is justified when: you need to abstract from the data source (DB + cache + external API) or when query logic is complex enough to isolate.
Jobs, Events, Listeners. Everything that can be async — make async. Sending email, PDF generation, external API sync, aggregate recalculation — into Queue. Laravel Horizon for queue monitoring in Redis: see throughput, failed jobs, processing time per queue.
How Octane handles high load
Laravel Octane with RoadRunner or Swoole keeps the app in memory between requests — removes bootstrap overhead (config loading, class autoloading) on each HTTP request. Gain: 3–8x on synthetic benchmarks, 2–4x on real applications. Important: no state between requests in static variables — that leads to exactly the incidents from the beginning. We use this in projects with >1000 RPS.
What to do about N+1 queries
N+1 is the most common cause of slow pages in Laravel apps. Standard story: page worked fine on dev with 10 records, on production with 10,000 — 8-second load.
Laravel Debugbar in dev environment shows the number of queries per page. More than 20 queries per page — signal for audit.
Model::preventLazyLoading(! app()->isProduction());
Telescope for profiling in staging: logs all queries, jobs, mail, notifications with time detail. Numbers: after implementing eager loading, page load time drops from 8s to 0.3s — 27 times faster.
PostgreSQL: indexes that are actually needed
PostgreSQL 14+ is the primary DB on all projects. We use PgBouncer + PostgreSQL combination. 10+ years experience, more than 50 backend projects, 5 years on the market.
How PostgreSQL helps avoid slow queries
Composite indexes for frequent WHERE + ORDER BY. If you have WHERE user_id = ? AND status = ? ORDER BY created_at DESC — you need (user_id, status, created_at DESC). A separate index on (user_id) doesn't help much with sorting.
Partial indexes. If 95% of queries go with WHERE status = 'active':
CREATE INDEX idx_orders_active ON orders (created_at DESC)
WHERE status = 'active';
The index is small, fast, covers the main load.
GIN indexes for JSONB and arrays. @> operator without GIN index — seq scan. With index — fast even on millions of rows.
GIN for full-text search. to_tsvector + GIN instead of LIKE '%query%'. LIKE without index is always seq scan. With pg_trgm extension and gin_trgm_ops — supports LIKE with index, useful for CRM search by partial match.
Connection pooling: why it's more important than it seems
Rails, Laravel, Django open a new connection to PostgreSQL for each PHP/Python process. With 100 workers — 100 connections. PostgreSQL starts degrading from 200–300 active connections — overhead on connection management becomes significant.
PgBouncer — connection pooler in front of PostgreSQL. Transaction pooling mode: connection to PostgreSQL is occupied only during a transaction, returned to pool between requests. 1000 application workers → 20–50 actual connections to PostgreSQL. This reduces latency by 40% and hosting costs by 30%.
Node.js with Fastify: when it's better than Laravel
Node.js is justified for:
- Realtime: WebSocket servers, Server-Sent Events, chat, live updates
- Streaming: large files, video, streaming data
- High I/O concurrency: many parallel requests to external APIs without heavy business logic
- Serverless: Lambda/Cloud Functions — Node.js starts faster than PHP
Fastify over Express: 2–3 times faster on benchmarks, built-in JSON Schema validation, better TypeScript support, plugin architecture.
Typical realtime architecture: Laravel — core business logic and REST API. Node.js + Socket.io or ws — WebSocket server. Laravel publishes events to Redis Pub/Sub, Node.js subscribes and broadcasts to clients. This separation allows scaling the WebSocket server independently of the main app.
Go: microservices and high load
Go we use for:
- High-load microservices (>10,000 RPS)
- Background workers with strict latency requirements
- DevOps tools and CLI
- gRPC services in microservice architecture
Goroutines — thousands of times cheaper than OS threads. 10,000 concurrent connections on Go is normal on one server.
But Go is not a silver bullet. Development is slower than Laravel: more boilerplate, no ORM at Eloquent level, error handling with if err != nil everywhere. Justified only when performance is a real requirement, not an assumption.
Django and Python backend
Django with DRF (Django REST Framework) — for tasks where Python is needed: ML pipelines, data processing, integrations with AI tools.
Celery for background tasks — similar to Laravel Queue but more complex to configure. Celery Beat for cron tasks.
Django ORM vs raw SQL: ORM is convenient for CRUD. For analytical queries with multiple JOINs, window functions, and CTEs — connection.execute() with raw SQL is more readable and predictable.
Redis: not just cache
Redis in our projects plays multiple roles:
| Role |
Details |
| Cache |
Caching results of heavy queries, HTML fragments |
| Queues |
Backend for Laravel Queue / Celery |
| Session store |
Distributed sessions in multi-instance environment |
| Pub/Sub |
Realtime events between services |
| Rate limiting |
Sliding window counters for API throttling |
| Leaderboards |
Sorted Sets for rankings |
Redis Cluster for horizontal scaling. Sentinel for automatic failover on standalone setups.
Deployment and infrastructure
Docker + docker-compose — standard for local development and production. Each service in a container: PHP-FPM/Octane, Nginx, PostgreSQL, Redis, Queue Worker, Scheduler.
CI/CD via GitHub Actions:
- Run tests (PHPUnit / Pest, Vitest, Playwright)
- Build Docker image
- Push to Container Registry
- Deploy: docker pull → docker-compose up -d on server, or Kubernetes rolling update
Zero-downtime deploy for Laravel: php artisan down --secret=TOKEN is not needed with proper configuration. Strategy: new container starts next to the old one, Nginx switches traffic after health check, old container stops.
Monitoring: Sentry for exception tracking with alerting in Slack/Telegram. Grafana + Prometheus (or Grafana Cloud) for metrics: CPU, memory, request rate, queue depth, database connection count. Alerts on: error rate > 1%, p99 latency > 2s, queue depth > 1000 jobs.
What's included in turnkey work
- Architecture design (API documentation, DB schema, service diagram)
- Implementation according to agreed specification with code review
- CI/CD, monitoring, alerting setup
- Load testing (k6, wrk) with report
- Handover of source code, access, deployment instructions
- Training of customer's team (2-3 sessions)
- Warranty support for 1 month after delivery
Timeline benchmarks
| Task |
Timeline |
| REST API for mobile/SPA (medium complexity) |
6–12 weeks |
| Backend with complex business logic + integrations |
12–20 weeks |
| High-load service on Go |
8–16 weeks |
| Migration from legacy PHP to Laravel |
16–32 weeks |
Pricing is calculated individually after analyzing load, integrations, and business logic. Contact us for a free audit of your current backend — get an optimization plan in 2 days. Request a consultation.