Shinkarenko
Menu

Project

AI Telegram Automation

Promotional emails turned into approved Telegram posts, and a customer bot with an AI consultant, delivery calculator and order capture.

Four connected n8n workflows for a Telegram-based business that buys goods in the EU and delivers them to CIS countries. They solve two problems: turning promotional emails into channel posts without manual copywriting, and answering customers around the clock.

Email to channel post, with human approval

  • Gmail is polled every minute for emails under one label, so only the offers the owner selected are processed.
  • Each message ID is looked up in Supabase before any work starts: no duplicate posts and no wasted LLM calls.
  • The email is stripped of HTML, scripts and tracking links and trimmed to fit the model’s context; the largest attached image becomes the banner and is stored in Seafile.
  • An LLM extracts the brand, offer, dates, promo code and conditions and writes a short Russian post. If the primary model fails, a fallback model takes over.
  • A custom escape step keeps the bold markup valid for Telegram MarkdownV2, avoiding the “can’t parse entities” errors that often break bots.
  • The draft is saved and sent to the owner with Publish and Regenerate buttons; a separate error workflow reports any failure.

A second workflow handles the buttons. Publish sends the post to the channel, as a photo with caption when there is a banner. Regenerate asks the model to rewrite the draft with the same facts and updates the approval message in place; Decline closes it. The action and the draft ID travel in the button data, so the handler is stateless. Nothing reaches the channel without the owner’s tap.

Customer bot: AI consultant and delivery calculator

  • An AI agent answers from the service’s own rules (ordering, delivery times, payment, prohibited items, commission, insurance, returns, customs limits) through RAG over Supabase pgvector, instead of guessing.
  • A live exchange-rate tool converts prices such as “89 EUR” or “1,500 CZK” to rubles with the correct cross rate; every quote says it is preliminary.
  • Per-chat memory keeps the conversation natural, and validated structured output (question, calculation, order or fallback) routes each reply.
  • A button-driven calculator walks through carrier and parcel weight and reads the price and delivery time from a tariff table; its state lives in the button data, so no session storage is needed.
  • Orders from chat or from the calculator are written to the database, the owner is notified in Telegram and the customer gets a confirmation.

The complete Supabase schema was delivered as SQL: the vector table with its index and search function, a tariff table seeded with 16 bands across four carriers, and orders. A small loader workflow lets the client edit questions and answers and re-embed the knowledge base without touching code.

Results

  • Email-to-channel publishing reduced to a single approval tap.
  • Repetitive customer questions answered around the clock from a controlled knowledge base.
  • Delivery quotes in seconds instead of manual replies; every order captured and pushed to the owner in real time.
Type
Client project · n8n automation
Role
Automation engineer: all workflows, the AI agent and the database
Scope
4 connected workflows and the database schema
Stack
n8n, Telegram Bot API, OpenRouter (Claude, Gemma), OpenAI Embeddings, Supabase (Postgres, pgvector), Gmail API, Seafile, JavaScript