ChatGPTCreativeWritingAI score · 81/100AI-assisted edit · no obvious prompt-injection riskn8n.io

Trigger, Generate, and Auto-Publish Social Posts via Telegram and OpenAI

Input: Telegram text message → Process: read Google Docs brand rules, OpenAI Agent drafts per platform, Telegram approval → Output: PostWire publishes to LinkedIn/Facebook/Bluesky/Mastodon, results logged to Google Sheets

Some experienceStepsWorkflowPromptTip
Who
Content operators or small teams who need brand-consistent multi-platform social publishing
You get
Send a topic via Telegram to generate per-platform drafts; auto-publish after approval with results logged
You need
n8n · telegram · google-sheets · google-docs · serpapi · postwire

Constraints

Prerequisites: n8n instance; Telegram Bot (created via @BotFather); Google Docs/Sheets credentials; OpenAI API credential; SerpApi key (free tier sufficient); PostWire account and API key. Cost: per OpenAI and SerpApi pricing; PostWire requires registration and plan confirmation. Boundaries: template defaults to LinkedIn, Facebook, Bluesky, Mastodon; editable in the Read the posts node; AI-generated content requires approval before publishing.

What they did

Template author postwire built an n8n workflow: a user sends a text topic to a Telegram Bot; the workflow filters out empty messages and commands, reads brand rules from Google Docs, and passes them to an OpenAI AI Agent (with SerpApi search tool attached) to generate drafts for LinkedIn, Facebook, Bluesky, and Mastodon as a JSON object. The drafts are sent to the user for approval via Telegram; upon approval, the workflow calls the PostWire API to publish per-platform text, appends results (success links or failure reasons) to Google Sheets, and replies to the user via Telegram. If the user declines, a discard confirmation is sent instead.

How it went

The source describes the expected workflow behavior: the Agent follows brand rules and optionally searches for facts; after approval, PostWire publishes and results are logged (author_report). This site has not tested the workflow and does not guarantee platform API availability or publish success rates.

Worth knowing

1. This template depends on the third-party PostWire service; users must register separately and obtain an API key. PostWire availability, pricing, and supported platforms may change and should be verified by the user. 2. The Agent’s systemMessage demands a single JSON object; if the model deviates from this format, the Read the posts node’s regex extraction may yield an empty object, causing draft sending to fail. 3. The template defaults to gpt-5-mini in workflow.json parameters; actual execution depends on the user’s OpenAI credential and model availability. 4. Google Sheets must be pre-created with columns date, topic, status, links, and note; otherwise append operations will error. 5. All Telegram nodes use parse_mode HTML, and special characters in drafts are escaped; modifying output formats requires attention to HTML tag validity. 6. This site has not executed the workflow; reproduction=not_tested. Users should validate the full pipeline in an isolated environment with a test topic first.

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • After import, connect your own credentials on auth-required nodes; author secrets are not included.

Configuration to replace

  • Source template is n8n public workflow #20505 (~22 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
  • Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.

Test input and expected output

  • Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
  • Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.

Template changes

  • Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No business-logic edits; verify keys, quotas and privacy compliance before use.

Template retrieved: 2026-10-24

Steps

  1. Configure Telegram trigger and filter

    Add a Telegram Trigger node in n8n, select your Telegram Bot credential, and listen for message updates. Add a Filter node (Only text topics) with two conditions: message text is not empty, and does not start with “/” (to exclude commands). Once saved, sending a text message to your bot will trigger the workflow.

  2. Set up Google Docs brand rules retrieval

    Add a Google Docs node (Get the brand rules), connect your Google credential, and enter your brand rules document URL in the documentURL field. The document content is passed as part of the system context to the AI Agent to control tone, audience, and words to avoid.

  3. Configure AI Agent to generate multi-platform drafts

    Add an AI Agent node (Write the posts with an AI agent), set promptType to define. In the text field, use an expression to concatenate the Topic and Brand rules; in options.systemMessage, enter the system instruction requiring JSON output per platform. Connect the OpenAI Chat Model node to the Agent’s ai_languageModel socket; connect the SerpApi node to the ai_tool socket for factual search when needed.

    Execution prompt · Source text。AI Agent node text field (define mode); dynamically concatenates topic and brand rules at runtime

    ={{ 'Topic: ' + $('Only text topics').item.json.message.text.trim() + '\n\nBrand rules:\n' + ($json.content || 'No brand rules yet: write in a clear, friendly, professional voice.') }}

    Execution prompt · Source text。AI Agent node options.systemMessage field

    You are the social media writer of a brand. Follow the brand rules in the message exactly: voice, audience, words to avoid.
    When the topic needs current facts, search Google once or twice and use only what you find. Never invent facts, numbers, quotes or links.
    Answer with one JSON object and nothing else, with these keys:
    - linkedin: 3 short paragraphs, professional, no hashtags.
    - facebook: 1 or 2 conversational sentences.
    - bluesky: up to 280 characters, no hashtags.
    - mastodon: up to 450 characters with 2 hashtags.
    - sources: an array with the URLs you used (empty when you did not search).
  4. Parse output and send drafts via Telegram

    Add a Set node (Read the posts) to extract JSON from the Agent’s output using an expression, parsing it into a posts object; also fix the networks array as ['linkedin', 'facebook', 'bluesky', 'mastodon'] and record chat_id and message_id. Then add a Telegram node (Send the drafts) to send the parsed draft list to the same chat_id using HTML parse_mode.

    Execution prompt · Source text。Telegram node Send the drafts text field

    ={{ (() => { const p = $json; const drafts = p.networks.filter(n => p.posts[n]).map(n => '<b>' + n.toUpperCase() + '</b>\n' + String(p.posts[n]).replace(/&/g, '&amp;').replace(/</g, '&lt;')).join('\n\n'); return (drafts || 'The agent returned no posts. Decline and send the topic again.').slice(0, 3900); })() }}
  5. Request approval in Telegram

    Add a Telegram node (Ask for approval in Telegram), set operation to sendAndWait, responseType to approval, approveLabel to “Approve”, and disapproveLabel to “Decline”. The user receives the drafts and taps Approve to enter the publish branch, or Decline to enter the discard branch.

  6. Publish, log results, and reply

    On the Approve branch: add an HTTP Request node (Publish with PostWire), method POST, URL https://postwire.io/api/post, authentication set to genericCredentialType → httpHeaderAuth, with Header Authorization: Bearer <PostWire API key>. The jsonBody uses an expression to construct platforms, text, per_platform, and idempotency_key. Then use an If node (Every network published?) to check full success: if all succeed, route to a Google Sheets node (Log the posts) to append the record, and a Telegram node (Reply with the links) to reply with URLs; if any fail, route to a Google Sheets node (Log the failure) to record the reason, and a Telegram node (Reply with the fix) to reply with specific fix guidance. If the user taps Decline, a Telegram node (Reply that nothing was published) replies “Discarded. Nothing was published.”

    Execution prompt · Source text。Telegram node Reply with the links text field

    ={{ 'Published everywhere:\n' + String(($('Publish with PostWire').item.json.results || []).map(r => r.platform + '  ' + (r.url || 'processing, the link appears in PostWire')).join('\n')).replace(/&/g, '&amp;').replace(/</g, '&lt;') }}

    Execution prompt · Source text。Telegram node Reply with the fix text field

    ={{ 'Not published everywhere:\n' + String((() => { const r = $('Publish with PostWire').item.json; return r.error ? r.error : (r.results || []).map(x => (x.ok ? 'Published  ' : 'NOT published  ') + x.platform + (x.url ? '  ' + x.url : '') + (x.ok ? '' : '\n    ' + (x.fix || x.error))).join('\n'); })()).replace(/&/g, '&amp;').replace(/</g, '&lt;') }}

Prompt you can copy

Setup guidance · Editorial suggestion。Setup assistant; confirm inputs and permissions first

This block is the prompt. Ads are never placed here.

You are an n8n workflow setup assistant. The user wants to replicate a Telegram → OpenAI → PostWire social media publishing factory. First confirm whether the user already has: Telegram Bot, Google Docs/Sheets access, OpenAI API key, SerpApi key, and PostWire API key. Then guide them to import the template or build nodes manually, with special attention to the AI Agent’s systemMessage and text expression, the PostWire HTTP Header Auth format, and whether the Google Sheets columns match date/topic/status/links/note. Recommend triggering once with a test topic to verify the Agent’s JSON output is parsed correctly.

To change target platforms, edit the networks array in the Read the posts node; to swap the model, replace the model field in the OpenAI Chat Model node.

Source

Create and publish social posts via Telegram, OpenAI, Google Docs and PostWire · postwire · n8n.io · 2026-10-06

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related