Skip to main content

Building Workflows

Workflows automate multi-step processes across social media platforms, AI models, RSS feeds, webhooks, and third-party integrations. This guide covers how to build, test, publish, and activate workflows programmatically via the REST API or through AI tools.

๐Ÿ—๏ธ Workflow Architecture

Every Posttu workflow consists of:
  1. Container (Workflow): Stores workspace metadata (name, description, active status) and versions.
  2. Draft Version (WorkflowVersion): The editable canvas workspace containing a Trigger and one or more Steps.
  3. Trigger (WorkflowTrigger): The event or schedule that initiates execution (e.g. schedule, webhook, rss_new_item, channel_new_comment).
  4. Steps (WorkflowStep): Action nodes (e.g. ai_ask_ai, x_create_post, http_request, condition, loop, delay, code) arranged in a linked list sequence or nested within containers.
  5. Expressions ({{...}}): Dynamic template tags that reference data from triggers, preceding steps, or loop iterations.
  6. Published Version: An immutable release snapshot promoted from the draft. Workflows must be published before they can be activated in production.

โšก 6-Step Workflow Construction Protocol

Follow this 6-step lifecycle to build, verify, and launch a complete workflow:

Step 1: Discover Available Integrations, Pieces & Connections

Before constructing steps, inspect the piece catalog to discover available actions, input schemas, and active workspace authorizations:

Step 2: Create a Workflow Container

Create a new workflow container to receive an empty draft version:
Save the returned id (e.g. wkf_abc123) for subsequent requests.

Step 3: Configure the Workflow Trigger

Attach and configure the starter trigger for the workflow draft. For schedule triggers, always specify scheduleType ("cron", "interval", or "preset") inside settings โ€” otherwise the scheduler defaults to daily at 9:00 AM UTC:

Supported Trigger Types

[!TIP] If using the webhook trigger, call GET /api/v1/workflow/wkf_abc123/webhook after setting the trigger to retrieve the unique public inbound URL (https://posttu.com/api/workflows/wkf_abc123).

Step 4: Add Action Steps, Branches & Loops

Add execution steps to the draft canvas using POST /api/v1/workflow/{id}/step. Steps can be linear, placed inside conditional branches, or placed inside loop iterators.

1. Linear Action Step (AI Text Completion)

ai_ask_ai accepts prompt (required), optional systemPrompt, inputText, creativity, maxRetries, and continueOnFail, and returns { text, usage, finishReason }:

2. Social Platform Post Action (channel) vs Third-Party Integrations (__connectionId)

  • Posttu social publishing actions (e.g. x_create_post) take a connected Posttu social channel ID (from GET /api/v1/channels/list).
  • Third-party piece actions requiring external OAuth/API credentials (e.g. Gmail, Notion, HubSpot) pass "__connectionId" from GET /api/v1/workflow/connections.

3. Conditional Router Step (condition)

The condition router splits flow execution into branches:
[!IMPORTANT] Condition Router Field Syntax: In condition.field, provide the raw dot-path string (e.g. "trigger.body.priority", "steps.step_1.status"). Avoid wrapping field in {{...}}.

4. Adding Steps Inside a Condition Branch

To place an action node inside a specific branch, set parentStepId to the condition stepโ€™s ID, and set branchId to the branchโ€™s ID:

5. Loop Iteration Step (loop)

To iterate over a list of items:
Inside the loop body, child steps use parentStepId: "<loop_step_id>" and access current item properties via {{loop.item.property}} and {{loop.index}}.

Step 5: Test Workflow Draft

Run an isolated test execution against the draft version to verify parameter resolution and output values. triggerPayload becomes the root trigger object (so for webhook triggers that reference trigger.body.*, wrap fields inside "body"):

Step 6: Publish Draft (and Pause / Re-Activate)

Publishing a draft creates an immutable release version and automatically activates production schedules and event listeners. Use /active afterwards to pause (isActive: false) or re-activate (isActive: true) a published workflow:

๐Ÿ”ค Dynamic Expression Syntax & Convergence

Step settings support Mustache template expressions to pass data between nodes.

Expression Namespaces

Branch Convergence Output (mergedData)

When a condition router finishes executing its matching branches, the outputs from all branches converge into the condition stepโ€™s output under mergedData:
  • KEYED_OBJECT (Default): Access branch results via {{steps.<condition_id>.mergedData.<branchId>}}.
  • ARRAY: Access branch results by array index via {{steps.<condition_id>.mergedData[0]}}.
  • DEEP_MERGE: Access combined object properties via {{steps.<condition_id>.mergedData.<field>}}.

๐Ÿ“‹ Complete Blueprint: Inbound Webhook to Router & Platform Post

Below is a complete multi-step blueprint demonstrating webhook triggers, condition branching, and downstream execution:
Last modified on November 22, 2026