Quick overview
This workflow turns a Telegram message into an approved AI-generated image post by using Google Gemini for captions and prompts, Cloudflare Workers AI for image generation, Google Drive for hosting, and the Facebook Graph API to publish to a Facebook Page and Instagram.
How it works
- Triggers when a new Telegram message arrives, ignores empty messages and commands, and loads your brand context and Meta account IDs.
- Sends the request to Google Gemini to generate a JSON response containing an image prompt and a ready-to-post caption.
- Sends the caption to Telegram for approval and, if rejected, regenerates once before flagging the request for manual review.
- When approved, generates a square image with Cloudflare Workers AI (Flux), converts it to a 1440×1440 JPEG, uploads it to Google Drive, and makes the file publicly accessible.
- Sends an image preview to Telegram for approval and, if rejected, regenerates once before stopping and requesting manual review.
- If approved, posts the image and caption to your Facebook Page and creates and publishes an Instagram media container via the Facebook Graph API, polling until the container is ready.
- Appends a published log entry (timestamp, prompt, image URL, status) to a Google Sheets tab.
Setup
- Create and connect a Telegram bot credential, then start a chat with the bot so it can receive messages.
- Add a Google Gemini API key as an HTTP Header Auth credential (x-goog-api-key) for the Gemini request.
- Add a Cloudflare Workers AI API token as an HTTP Header Auth credential, and replace YOUR_CLOUDFLARE_ACCOUNT_ID in the image-generation request URL.
- Connect Google Drive OAuth and choose the target folder for uploads, noting the workflow makes images public so Meta can fetch them by URL.
- Connect Google Sheets OAuth, set YOUR_GOOGLE_SHEET_ID, and create a tab named “Log” with columns timestamp, prompt, image_url, and status.
- Connect a Facebook Graph API credential with permissions to post to your Facebook Page and Instagram Business account, and fill in your Facebook Page ID and Instagram user ID in the brand context settings.