Quick overview
Automate multi-photo Facebook posts from Telegram albums. This workflow buffers incoming photos, uses OpenRouter AI to generate engaging social media captions, uploads media in bulk, and publishes the final post while sending a clickable live link back to your chat.
How it works
- Triggers when a new Telegram message containing photos arrives.
- Extracts the best-resolution photo, caption, and a media-group key, then stores each photo entry in an n8n Data Table.
- Waits briefly to allow all images in the same Telegram album (media group) to arrive, then retrieves all stored records for that album.
- Collects the first non-empty caption and builds a list of photo file IDs for the album.
- Uses OpenRouter to rewrite the caption into an engaging Facebook post with a hook, CTA, and hashtags.
- Downloads each Telegram photo and uploads it to the Facebook Graph API as unpublished media to obtain media IDs, then aggregates them into an attached_media array.
- Publishes a Facebook Page feed post with the AI-generated message and attached media, then sends a Telegram notification containing the Facebook post URL.
Setup
- Connect a Telegram Bot credential and ensure the bot can receive photo messages in the target chat or group.
- Create (or select) an n8n Data Table for buffering album items with columns for media_group_id, file_id, caption, and date.
- Add an OpenRouter API credential and choose the model you want to use for caption rewriting.
- Add a Facebook Graph API credential with a Page access token that can publish posts, and replace the hard-coded Facebook Page ID (node value 1285698161296966) with your own.
- Review the wait time used to batch Telegram albums (currently 3 seconds) and adjust it if your albums arrive more slowly.