What the agent does
This is for a company that sells marketing software to independent gyms, CrossFit boxes and boutique fitness studios. Most of its customers schedule their Instagram and Facebook posts in Buffer on a Sunday night, when the coaching is done, and most weeks something slips: Tuesday and Wednesday are empty, a channel was disconnected when the owner changed their Facebook password, or a post sits in error because an image was too large. A gym that goes quiet online in January loses the people who were deciding whether to join. The software adds a Friday Queue check that tells each gym owner what next week looks like while there is still a weekend to fix it.
The company saves the agent once as a template with POST /o/{org}/agents, with "connections": ["buffer"] (it connects a Buffer account of its own first, because a template names connections its creator has). When a gym turns the check on, the backend calls POST /o/{org}/agents {"template": "<template id>", "name": "queue-<gym id>"}, then POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "buffer"}, and opens the authorize_url in a popup while the owner is signed in to the software. The owner signs in on Buffer's page to Rush's Buffer app client, so the company registers no Buffer app, and the agent reaches Buffer's GraphQL API at api.buffer.com signed from outside its computer.
On a run the agent reads the gym's organization with account { organizations { id name } } and its channels with channels(input: {organizationId}), keeping each channel's name, service, timezone, isQueuePaused, isDisconnected and isLocked. Buffer documents that a paused queue's scheduled posts will not be published and that a locked channel cannot be used for posting, so those come first in the report. Then it queries posts with a filter of status: [scheduled, needs_approval, draft, error], the gym's channelIds and dueAt from Monday to Sunday of next week, paging with first and after.
It lays the week out per channel, day by day in that channel's own time zone, and lists every day with no scheduled post, every post still needs_approval or draft that will not go out on its own, and every post in error. For each empty day it writes one idea from the gym's class schedule and events in input, such as a Saturday partner workout or a new 6 a.m. class, and saves it with createIdea. Buffer keeps ideas at the organization level with no channel and no time, so nothing it saves can publish. It never calls createPost or edits a post already in the queue.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "<agent id>",
"input": "Check our Buffer queue for next week, Monday 2026-11-23 to Sunday 2026-11-29. Our schedule: Mon-Fri 6am, noon and 5:30pm classes; Saturday 9am partner WOD (bring a friend free); new Sunday 10am mobility class starting 11-29; closed Thursday 11-26 for Thanksgiving. Voice: upbeat, no hashtags except #IronHarborFit. 1) Read account organizations, then channels for our organization: name, service, timezone, isQueuePaused, isDisconnected, isLocked. 2) Query posts for our organization with status scheduled, needs_approval, draft and error, our channelIds, and dueAt from 2026-11-23T00:00:00 to 2026-11-30T00:00:00 in each channel's timezone, paging with first and after. 3) Write queue-check.md: channels that are paused, disconnected or locked first; then per channel, each day with its scheduled posts or EMPTY; then posts in needs_approval, draft or error with dueAt and text. 4) For each empty day on Instagram or Facebook, write one idea using only the facts above and save it with createIdea (title: the day and channel). Do not call createPost or change, schedule or delete any post. Return JSON: {empty_days: [{channel, date}], problems: [string], ideas: [{idea_id, title}]}."
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
The run checks next week's queue for channel problems, empty days and new post ideas waiting in Buffer. The session returns queue-check.md as an artifact and the JSON as its answer, which the software's webhook handler turns into Friday's email to the owner: problems first (a disconnected Facebook page, a paused Instagram queue, a post that failed), then the empty days, then a link to the new ideas waiting in Buffer.
What the owner checks before the weekend: that an empty day is not empty on purpose, like the Thanksgiving closure; that each idea says something true about the gym, since it only knows the schedule it was given; and any post in error, whose text and media the owner fixes in Buffer before it can go out. The owner turns an idea into a post in Buffer, picks the photo and the time, and schedules it. A disconnected channel is reconnected by the owner in Buffer, with the social network's own sign-in.
Run it on every Friday afternoon, per gym
The software's scheduler sends one POST /o/{org}/sessions per gym with the check on, at 14:00 on Friday in the gym's time zone, with that gym's agent id as agent, next week's dates and the gym's class schedule from the software in input, and a request_id that is a UUID v5 of the gym id and the week, so a retried job starts no second run. The key's webhook delivers each run.completed to the software.
Gyms that post every day can also get a Sunday evening run for the coming week; it is the same request with fresh dates, and a gym's agent never sees another gym's channels.
The use case this job follows, with its automation and trigger: Run an agent per customer task.
Why run it on Rush?
Each gym's Buffer sign-in is the gym's own and lives in Rush's connection under that gym's agent, refreshed by Rush; the software company stores no Buffer token and runs no Buffer app client. A run of one gym's agent reaches only that gym's Buffer organization, and the session's accounts names the account it used.
Each run has its own computer and a record of every GraphQL query and mutation it sent, so when an owner asks why an idea appeared in their Buffer, the software can show the run that saved it and the schedule it was given. The cost of each gym's runs is on its sessions, which is what the company needs to decide whether the check belongs in every plan.
Frequently asked questions
Will the agent post or schedule anything?
No. It saves ideas, which Buffer keeps at the organization level with no channel and no time, and the prompt forbids createPost and any change to an existing post. The Buffer sign-in could schedule posts, so the rule is in the template's instructions and every prompt, and the run's record shows each mutation.
Why are drafts and posts waiting for approval listed separately?
Buffer gives a post a status, and only scheduled posts are in the queue to publish. A draft or needs_approval post on an otherwise empty day still leaves that day empty unless someone acts, so the report lists them with their dates.
What if a gym has several locations in one Buffer account?
The agent reads every channel in the gym's organization. The software can send the channels for one location in input, and the agent filters the posts query to those channelIds.
Does the gym owner need a Rush account?
No. The owner signs in to Buffer only, from the popup in the software. The agent, its runs and their cost belong to the person at the software company who created the API key.
More Buffer jobs
More jobs like this: Run an agent per customer task
- List Every Google Drive File Shared With Anyone Who Has the Link, for Each Client Office (Google Drive)
- Which Client Trips Had a Flight or Hotel Change Overnight? A Travel-Advisor App Reads Each Advisor's Gmail Every Morning (Gmail)
- Which Klaviyo Flows Quietly Stopped Sending? An Email Reporting App's Weekly Check of Each Store's Live Flows (Klaviyo)