# Social Post Factory

> Paste a post idea, review the draft in chat, and publish with one confirmation: LinkedIn posts it, or Google Blogger publishes it and Telegram announces the link. The agent remembers your brand voice and tracks your weekly goal.

**URL:** https://caywork.com/learn/docs/agent-example/social-post-factory

## Content

The Social Post Factory turns a rough idea into a finished social post, with you in control of every publish. You paste an idea, the agent writes a draft for you to review, and nothing goes live until you say so. When you do approve, the flow checks the target channel and publishes in the right place. This example teaches the full draft, review, publish loop across three channels.

When you send a message, for example "why we built our agent in public, target channel linkedin", this is what happens:

1. The Chat Text Input triggers the flow. Your message is the post idea and the target channel. In this example the channel is written as target_channel, and its value is "linkedin" for LinkedIn or "blogger" for the blog-and-Telegram route.
2. The Tool Calling Node receives your message. It is the tool hub: the LinkedIn tool, the Google Blogger tool, and the Telegram tool all connect into it. It routes your idea and channel value to the Text Generator Node.
3. The Text Generator Node writes the post draft: one hook line to open, 2-3 body lines, then one CTA line. It does not publish anything. The draft appears in your chat.
4. You read the draft. If you want changes, just say so — the agent rewrites it. Because Conversation History is on, the agent remembers corrections you made earlier in this chat, so it keeps applying them without being reminded.
5. When you are happy, you type "post it". Only now does the flow publish. The Tool Calling Node passes the approved draft and the target_channel value to the Condition Node.
6. The Condition Node checks one thing: is target_channel equal to "linkedin"? If yes (True branch), the LinkedIn tool creates the post with the approved draft. If no (False branch), the Google Blogger tool publishes it as a blog post, and the Telegram tool sends a short announcement with the blog link.
7. Both branches return to the Tool Calling Node, which confirms the publish in chat with the link. The LinkedIn route shows the post URL; the Blogger route shows the blog URL and the Telegram announcement.

Nothing publishes without your "post it" in that conversation. If a publish fails (for example the LinkedIn token expired), the agent says so in chat instead of inventing a link.

## Platform features used

- Goals & Milestones (turn on in Flow Settings, the "Goals & Milestones" toggle): the agent tracks up to 5 goals across chats. Tell it "track the goal: publish 5 posts this week" and it counts each confirmed publish against that goal. The goal tracks progress; it does not schedule anything — you still publish manually by chatting.
- Conversation History (turn on in Flow Settings, the "Conversation History" toggle, with "Last N messages", default 20): the agent sees your recent turns in the same chat, so when you correct the brand voice ("shorter hooks, no exclamation marks"), it keeps applying that correction to later drafts in this chat. For memory that survives across chats, also turn on Long-Term Memory in Flow Settings.

## The Prompt for The Agent

You are a social post writer and publisher. You receive a post idea, the target channel (target_channel), and optionally user feedback on a draft. Your job has two phases: draft, then publish on approval.

Rules:

1. Phase one — draft. When the user sends an idea, write exactly one draft: one hook line, 2-3 body lines, then one CTA line. Do not publish.
2. End every draft with the line: Target channel: {target_channel}. If the user did not name a channel, ask which one before writing.
3. Apply brand-voice corrections the user gave earlier in this conversation. If they said "shorter hooks", every later draft uses shorter hooks.
4. Publish ONLY after the user says "post it" (or a clear approval like "yes, publish"). Rewrites, comments, and questions never publish.
5. On approval, publish to the channel in target_channel: "linkedin" means LinkedIn Create Post; anything else means Google Blogger Create Post, then a Telegram announcement with the blog link.
6. Never invent links. Report only the URL the publish returns. If a publish fails, say what failed and stop.
7. Count each confirmed publish toward the user's stated goal (for example "5 posts this week") and mention the count when asked.

Output template (draft phase):

{hook line}

{body line 1}
{body line 2}
{body line 3}

{CTA line}
Target channel: {target_channel}

Say "post it" to publish, or tell me what to change.

Output template (publish phase):

Published to {LinkedIn / the blog}: {url}
{one line: Telegram announcement sent with the link — only on the Blogger route}
{one line on goal progress, only if the user set a goal}

Formatting example (draft):

Idea: "why we built our agent in public"

We shipped our first agent with 0 users watching. Here is what broke.

The first draft confused every beta tester who read it.
We rewrote the prompt 4 times before anything worked.
Publishing the broken versions got us better feedback than any survey.

Follow along as we build in public.
Target channel: linkedin

Say "post it" to publish, or tell me what to change.

Formatting example (publish):

Published to LinkedIn: https://www.linkedin.com/feed/update/urn:li:share:7312345678901234567
2 of 5 posts published this week.

Tone and style:

- Write like a person, not a press release. Short lines, no emoji unless the user asks.
- The hook earns the read; the CTA earns the click. Keep both under 12 words.
- Never mention tools, JSON, counts you dropped, or the branch logic.

## Formatting Contract

The output is always one chat message per turn:

1. Draft phase: the hook, the body lines, the CTA, the "Target channel:" line, and the one-line publish invitation.
2. Publish phase: "Published to {channel}: {url}" first, then the Telegram line on the Blogger route, then the goal line if a goal exists.
3. Correction phase (user asked for changes): the new draft in the same shape, no publish, no apology needed.
4. If the channel is missing, the message is only the channel question. If a publish fails, the message is only the failure and what to check (connection, token). No link is ever reported unless the publish returned one.

## Nodes and Roles

| Node | Role |
|---|---|
| Chat Text Input | Input: takes the post idea, the target channel, and your "post it" approval |
| Tool Calling Node | Logic: the tool hub — LinkedIn, Blogger, and Telegram connect here; it routes drafts, runs the approved publish, and reports links |
| Text Generator Node | Logic: writes the draft (hook, 2-3 body lines, CTA) and applies your brand-voice corrections; never publishes |
| Condition Node | Logic: checks target_channel == linkedin and picks the publish branch |
| LinkedIn Node | Tool: creates the LinkedIn post on the True branch (Create Post action enabled) |
| Google Blogger Node | Tool: publishes the blog post on the False branch (Create Post action enabled) |
| Telegram Node | Tool: sends the announcement with the blog link on the False branch |
| User Chat Output | Output: delivers the draft for review, then the confirmation with the published links |