Flows
Chain endpoint calls, browser sessions and skills, scripts, AI questions, waits and if/else branches into one job; each step reads what earlier steps returned.
View as MarkdownA flow is a job made of steps that run in order. Each step does one kind of work, and a later step reads what the earlier ones returned. Read the most popular news, ask the AI whether it fits your account, have it write a post, and publish it on Threads, all in one job, once or on a repeat.
Run a flow
In the dashboard, Flows builds a flow on a canvas: each step is a node, an If/else or an AI yes-or-no step splits it into a Yes and a No path, Run asks for the input of that run and shows on every node what it returned, and Save keeps the flow. Its first node, Start, sets the values each run asks for and adds a timetable if it should also run on its own. A flow of one request, script, browser session or skills run is saved as that plain job, and bills as one. From code:
curl https://api.hoshime.com/v1/jobs \
-H "Authorization: Bearer $HOSHIME_TOKEN" \
-d '{
"flow": {
"input": { "persona": "a food blogger in Jakarta" },
"steps": [
{ "id": "news", "endpoint": { "platform": "kompas", "endpoint": "popular" } },
{ "id": "fits", "ai": {
"mode": "decide",
"prompt": "Would {{input.persona}} share this news with their followers?",
"input": "{{news.data.0.title}}"
} },
{ "id": "post", "if": "{{fits.yes}} == true", "ai": {
"mode": "write",
"prompt": "Write a short Threads post in Indonesian about this news, as {{input.persona}}.",
"input": "{{news.data.0.title}} {{news.data.0.url}}"
} },
{ "id": "publish", "if": "{{fits.yes}} == true", "skills": {
"profileId": "bpr_2Xc...",
"steps": [{ "skill": "threads.createThread", "params": { "text": "{{post.text}}" } }]
} }
]
}
}'
The answer is the queued job. Read it with GET /v1/jobs/{jobId} until its status is succeeded or failed; flowResult.steps lists what each step did.
Steps
Each step has an id (a letter, then letters, digits or _, at most 32) and exactly one of these:
| Step | What it does | Its result |
|---|---|---|
endpoint |
Calls a public data endpoint: platform, endpoint, params |
{data, nextCursor} |
request |
Sends an HTTP request, as a request job does | {statusCode, body}, the body decoded when it is JSON |
browser |
Runs a browser session, as a browser job does | {finalUrl, httpStatus, evaluateResults} |
skills |
Runs browser skills with a signed-in profile, as a skills job does | the skills result, such as the posts a search found |
script |
Runs a sh or bun script, as a script job does |
what it prints: JSON when it prints JSON, otherwise the text |
ai |
decide answers whether prompt holds for input; write writes what prompt asks for from input |
{yes, p} or {text} |
wait |
Pauses the flow for seconds, at most a day, without holding a worker |
{until} |
check |
Branches the flow: whether its conditions hold, all of them (the default) or with match: "any" one of them. Runs no work and bills nothing |
{yes} |
A flow has at most 20 steps.
Placeholders
Any text of a step may hold {{input.key}}, a value of the flow’s input, or {{id.path}}, a value an earlier step returned: {{news.data.0.title}} is the title of the first item the news step read. Numbers pick an item of a list.
- A text that is only a placeholder takes the value as it is: a number, a list or an object. Otherwise the value is written into the text, an object or a list as JSON.
- A placeholder that names nothing (a missing key, an item past the end of a list, a step that was skipped) fails the step. A flow never goes on with an empty value.
- Placeholders are plain lookups. They never run code.
The flow fills an endpoint’s names and parameters, a request’s method, address, headers and body, a browser session’s url and input (its actions read that input as usual), a skills run’s profile, tunnel and parameters, and an AI question. It never fills a script: a script reads the flow’s input and every earlier result from the JSON file the HOSHIME_FLOW variable names.
# a sh step that keeps the posts with more than 1000 likes
jq '[.news.data[] | select(.likes > 1000)]' "$HOSHIME_FLOW"
Conditions
A step with if runs only when its condition holds, and is skipped otherwise. A condition is a placeholder alone, true unless its value is false, null, 0, "" or empty, or two values compared with ==, !=, >, >=, <, <= or contains:
{{fits.yes}} == true
{{news.data.0.likes}} >= 500
{{news.data.0.title}} contains "banjir"
Each side is a placeholder or a JSON value. A skipped step leaves no result. A step whose if reads a skipped step is skipped too, but a placeholder elsewhere in a step that names a skipped step fails it: give that step the same condition.
Branches
A check step, or an ai step with mode: "decide", splits a flow in two. The steps of its yes path have "if": "{{id.yes}} == true", those of its no path "if": "{{id.yes}} == false", and a step with no if after them runs whichever path was taken:
[
{ "id": "news", "endpoint": { "platform": "kompas", "endpoint": "popular" } },
{ "id": "flood", "check": { "conditions": ["{{news.data.0.title}} contains \"banjir\""] } },
{ "id": "post", "if": "{{flood.yes}} == true", "ai": { "mode": "write", "prompt": "Write a Threads post about it.", "input": "{{news.data.0.title}}" } },
{ "id": "save", "if": "{{flood.yes}} == false", "request": { "method": "POST", "url": "https://example.com/later", "body": "{{news.data.0.url}}" } },
{ "id": "log", "request": { "method": "POST", "url": "https://example.com/log" } }
]
A step whose if reads a skipped step is skipped too, so a branch inside a path that was not taken skips with it, and branches nest.
Retries
A step that fails tries again up to its maxAttempts, which defaults to the job’s. The steps before it never run again. Two kinds are careful:
- A
browserstep runs once unless itsmaxAttemptssays more, since it may have clicked or typed before it failed. - A
skillsstep tries again only when no skill ran, since a skill may have posted or liked.
A step that is out of attempts fails the flow. flowResult keeps what every step did, and a replay starts the flow over from its first step.
Billing
A flow bills 1 unit when it is queued, plus what its steps bill: an endpoint call its units (nothing when it is answered from the cache), an AI answer at least 10 units, and a request, script, browser session or skills run what its own job bills.
Saved flows and timetables
A saved flow is a schedule that takes flow in place of request. Without cron it runs only by hand; with one it also runs on that timetable while its status is active, and PATCH /v1/schedules/{scheduleId} with "cron": "" takes the timetable away again.
POST /v1/schedules/{scheduleId}/run runs a saved flow now, with input values that replace or add to its saved input for that run only:
curl -X POST https://api.hoshime.com/v1/schedules/sch_123/run \
-H "Authorization: Bearer $HOSHIME_TOKEN" \
-H "Content-Type: application/json" \
-d '{"input": {"caption": "New drop today #senja"}}'
The run is listed under the flow (GET /v1/jobs?scheduleId=sch_123). It is refused while the flow’s last run is still queued or running, so a flow that posts never posts twice at once.
With MCP, the run_flow tool queues a flow and get_job reads its outcome; call_operation with POST /v1/schedules/{scheduleId}/run runs a saved one, PUT /v1/schedules saves a flow by name, and read_operation with GET /v1/schedules lists the saved ones.