Quick Overview
This workflow scrapes a Russian joke from anekdot.ru, uses OpenRouter (chat + image) to turn it into a single-panel comic image, posts the image with a caption to Telegram, and tracks state and deduplication in Google Sheets while storing generated images in Google Drive.
How it works
- Starts manually (or on a schedule if you replace the trigger) and searches Google Drive for the history Google Sheets spreadsheet, creating it (plus an images folder) on first run.
- Loads the last processed page from the spreadsheet’s State tab, builds the anekdot.ru tag URL, downloads the page HTML, and extracts jokes that match the target length.
- Reads previously used joke hashes from the Used Jokes tab and selects the first unused joke, paging through anekdot.ru (up to 15 pages) until it finds a valid unused candidate.
- Sends the chosen joke text to an OpenRouter chat model to extract a strict JSON description (scene, characters, and short dialogue), then assembles a safe image prompt with optional speech bubbles.
- Generates a square comic image via the OpenRouter Images API, and if moderation blocks the request it logs the joke as blocked in Google Sheets and retries with the next unused joke.
- Converts the returned base64 image to a PNG, uploads it to Google Drive, shares it publicly, and posts it to Telegram with an HTML caption containing the joke text.
- Appends the sent joke hash, excerpt, timestamp, and Drive image URL to the Used Jokes tab and updates the current page in State if it changed.
Setup
- Add credentials for OpenRouter API, Telegram, Google Sheets OAuth2, and Google Drive OAuth2 (with the Google Sheets API and Drive API enabled).
- Set the Telegram chat ID in the Telegram “send photo” step to your target channel/chat numeric ID.
- Ensure the Google Drive search name and the Google Sheets spreadsheet title match exactly (default is “Anekdot Bot — History”), or change both to your preferred name.
- Optionally change the anekdot.ru tag in the URL-building code (default is “вовочка”) and the Google Drive folder name where images are stored.
- Select an OpenRouter chat model in the OpenRouter Chat Model node (the workflow ships without a preset model).
- If you want automatic posting, replace the Manual Trigger with a Schedule Trigger and activate the workflow.