Esta página no está disponible en español. Se muestra la versión en inglés.

Build your first workflow

Build, check, run, and approve a three-step workflow in Workflow Studio, from an empty canvas to a finished run. No outside accounts or API keys needed.

En esta página

In this tutorial you build a small approval workflow in Workflow Studio. It drafts a refund request, waits for a person to approve it, and records the decision. You will create it, check it, run it, approve it in Command Center, and read the result.

Who this is for: anyone new to AgentRuntime. You do not need to write code, but you will read a few lines of JSON and a short script.

What you will build:

StepTypeWhat it does
Draft the summaryluaBuilds a one-line summary of a refund request
Approve the refundhumanPauses the run and asks a person to approve or reject
Record the decisionluaRuns only after approval and records the outcome

This workflow needs no connections and no AI model key, so it runs in a brand-new workspace. When you finish, you can add an AI step or connect a real tool.

What you need

  • Access to the Console and a workspace and project selected in the header.
  • The project_contributor role or higher. project_viewer can look but not build or run. See Roles and permissions.
  • Credits in your workspace. Runs use credits according to your plan. See Billing and credits.

Build and run it

  1. Create the workflow

    In the Console sidebar, open Workflows and click Create workflow. If Studio opens the last workflow you worked on instead of the list, click the back arrow in the toolbar (Back to all workflows) first. The Find a workflow recipe dialog opens. Recipes are ready-made starting points. You will start empty instead.

    To name your workflow, scroll to Workflow name at the bottom of the right-hand panel and type a name, such as Refund request approval. Then click Blank canvas at the top right. You can rename the workflow later.

    The Find a workflow recipe dialog with Refund request approval typed in the Workflow name field
    Type a name under Workflow name, then click Blank canvas.

    You should see: an empty canvas with a toolbar along the top and a grey Draft chip. A card in the middle asks What should this workflow do? It can build steps from a description. You do not need it for this tutorial.

    An empty Workflow Studio canvas with the step palette on the left and the What should this workflow do? card
  2. Import the three steps

    The quickest way to get exactly the right steps is to import them. Copy the workflow JSON from the end of this page. In the toolbar, open the JSON menu (the { } JSON button with an arrow, at the far right) and click Import. In the Import Workflow dialog, choose From clipboard and paste the JSON. The Review import preview appears. Click Import.

    Nota

    The toolbar adapts to your window width. In a narrower window, the JSON menu is folded into More (the ⋯ button at the far right), which also has Import.

    The JSON menu open in the Workflow Studio toolbar, showing Export JSON, Import, Edit JSON and View JSON
    Import is in the toolbar's JSON menu.
    The Review import dialog showing three steps: Draft the summary, Approve the refund, Record the decision
    After you paste, Review import shows the steps before you import them.

    You should see: three steps connected left to right: Draft the summary, Approve the refund, Record the decision.

    The canvas with the three imported steps connected left to right
    Nota

    Import replaces whatever is on the canvas. It does not change the workflow's name. Studio replaces the short step IDs in the JSON (draft, review, decision) with its own long IDs, and it updates every reference to them. If you see long IDs in a step's settings or in the JSON, that is why.

  3. Look at each step

    Click a step to open its settings on the right.

    • Draft the summary has a Lua script field. Lua is a small scripting language for reshaping data. This script returns a table with the customer, the order, the amount, and a summary sentence. A Lua step must return a table.
    • Approve the refund is a Human step. It pauses the run and creates a task. The message the reviewer sees is {{steps.draft.result.summary}}. Under If no response (timeout policy) it says Keep waiting, and under When rejected it says Stop this branch. Its JSON has "approver": { "any_member": true, "allow_initiator": true }, so anyone who can edit the project may answer, including you, the person who runs it. Without that line, or a list of Required approvers, nobody could answer the task. See Human tasks.
    • Record the decision reads the reviewer's answer. In a script, the answer is steps["review"].result.approved.
    The settings panel of the Draft the summary step, showing its Lua script
    The Lua script of Draft the summary.
    The settings panel of the Approve the refund step, showing If no response set to Keep waiting and When rejected set to Stop this branch
    The settings of Approve the refund, a Human step.

    The double braces in {{steps.draft.result.summary}} are a template. At run time AgentRuntime replaces it with the summary field that the Draft the summary step returned. The pattern is {{steps.<step id>.result.<field>}}. To insert one without typing it, type {{ in a field and pick a suggestion. See Template intellisense.

    Nota

    The reviewer's message is set in the step's JSON (task_payload), not in the step settings. To change it, click JSON next to Canvas in the toolbar (or Edit JSON in the JSON menu), edit the text, then click Apply to canvas. Click Canvas to go back. View JSON shows the same JSON read-only. In a narrower window, More only offers View JSON, so widen the window to edit.

    The JSON view of the workflow with the task_payload title and message of the human step
    The JSON view. The reviewer's message is under task_payload.
  4. Connect the steps

    The import already drew the lines. A line means "run after". Approve the refund starts only when Draft the summary has finished, and Record the decision starts only after the approval. Steps with no line between them run at the same time.

    To build a line yourself, draw it from one step to the next. See Step types for what each type does and the settings every step shares.

  5. Dry-run it

    Click Dry-run in the toolbar. A dry-run checks that the workflow is well-formed without running anything: required fields, connections between steps, templates, and Lua syntax. See Dry-run validation.

    You should see: the Dry Run tab of the run panel at the bottom with Dry-run passed and no issues, and a "Workflow dry-run passed" message. If it lists an issue, it names the step and often suggests a fix.

    The Dry Run tab showing Dry-run passed with no issues and the list of checks performed
  6. Save it

    Studio saves your edits automatically after a couple of seconds; the chip next to the workflow name shows Draft · saved. You can also click the Save button (the disk icon) in the toolbar. There is nothing to publish yet: Run always runs your latest saved edits, which are called your draft. See Draft and published versions.

  7. Run it

    Click the green Run button in the toolbar. Studio starts a run of your draft, and the run panel at the bottom (Run logs and metrics) lists the new run. Click the run, then the Events tab.

    You should see: Draft the summary with the status Success, Approve the refund waiting, and the run marked Paused. This is expected: the run is waiting for a person, not stuck. While it waits, the toolbar shows Resume and Stop. You do not need either: the run continues on its own when someone answers the task.

    A paused run: Draft the summary succeeded and Approve the refund is waiting
  8. Approve it in Command Center

    Open Command Center in the sidebar. The Needs you chip shows 1.

    You should see: a row with your workflow's name, the label Approval, and the summary line "Refund $49.00 to Dana Lee for order A-1042 (item arrived damaged)."

    Command Center with one item under Needs your attention: Refund request approval, with View, Approve and Reject buttons

    Click Approve. The task leaves the list and the run continues. To see the task's details first, click View. See Command Center and Human tasks.

    Approving the task in Command Center.
  9. Read the result

    Go back to your workflow in Workflow Studio. In the run panel, click the run, which now shows Success, then open the Events tab.

    You should see: every step marked Success. Under Record the decision, Output shows what the step returned:

    {
      "approved": true,
      "message": "Refund of $49.00 for order A-1042 was approved."
    }
    The Events tab showing the Output of Record the decision with approved true and the message

    The Events tab lists every step in order, including when the task was created and answered.

  10. Try a rejection

    Click Run again. This time, click Reject in Command Center. A Reason (optional) box opens next to the button. Type a reason if you like, then click Reject again to confirm.

    Command Center with the Reason (optional) box open and the Reject button

    You should see: in the run's Events, Approve the refund marked Skipped · Approval rejected, with "approved": false and your reason as comment in its output. Record the decision never runs. This is what When rejected: Stop this branch does: the steps after the approval are skipped. The run itself still finishes with the status Success. Other choices, such as sending the work back for changes, are in Human tasks.

  11. Publish a version (optional)

    When you want a frozen copy that does not change while you keep editing, click Publish in the toolbar. The Publish v1 dialog explains that a published version never changes and that the draft stays editable. Add a note and click Publish v1, then Done.

    The Publish v1 dialog with a Note field and the Publish v1 button

    Triggers such as schedules and webhooks can then run Last published instead of Draft. Studio's Run button always runs the draft. See Workflow Studio.

Optional: add an AI step

You can make the draft smarter by adding an LLM step. It sends a prompt to a model.

  1. Add the step

    In the step palette, search for LLM under Built-in and click it, or drag it onto the canvas.

  2. Choose the model and key

    In its settings choose a Model, then an API key: the platform default or one of your accounts. Platform models depend on your plan. If your plan does not include them, add your own provider account on Connections first. See Models and provider accounts.

  3. Write the prompt

    Type a prompt and use a template to include the summary, for example: Write a friendly two-sentence reply to the customer about this refund: {{steps.<id>.result.summary}}. Type {{ to pick the Draft the summary step instead of typing its ID.

  4. Wire it in and show it to the reviewer

    Connect Draft the summary to the LLM step, and the LLM step to Approve the refund. The model's reply is on the step as result.text, so a template such as {{steps.<id>.result.text}} reads it. Dry-run again, then run.

An LLM step fails the run if the model call fails, so check the failed step's error in Events. See Troubleshooting.

Run it other ways

So far you started the run by clicking Run. A workflow can also start on its own. Each way is set up in Setup in the Workflow Studio toolbar. The Workflow setup dialog lists them on the left under Triggers: Manual, Inbound, Events, Cron, Sessions, API and Apps.

  • On a schedule. Open Setup, then Cron. Pick a Preset or type a Cron (5-field) expression, choose a Timezone, choose which version Runs (for example Draft), and pick an Automation API key (or click Create API key). Then click Add schedule. The shortest repeat is every minute. See Cron schedules.

    The Cron tab of Workflow setup with Preset, Cron (5-field), Timezone, Run as, Runs and Automation API key fields
  • From a webhook. Open Setup, then Inbound, and create a webhook. Another system sends a signed request to its URL, and the request body becomes the run's input. See Inbound webhooks.

  • From the API. Create an API key (a personal access token) under Settings, API keys with the workflow:run scope, then send a start command. The API tab in Setup shows your workflow's Command URL and a ready-made Example request you can copy. See API authentication.

    The API tab of Workflow setup with the Command URL and an example cURL request
    curl -X POST https://api.agentruntime.io/v1/workflows/WORKFLOW_ID/command \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"command": "start"}'
  • From a channel message. When a customer writes to you on a channel such as WhatsApp, a message can start a run or join an ongoing one-per-person conversation. See Conversation sessions.

Starting a run any of these ways still stops at the Approve the refund step until a person answers.

Common mistakes

MistakeWhat happensFix
Expecting the run to finish without youThe run shows Paused at the Human stepOpen Command Center and answer the task under Needs you
Walking away from an approvalAfter the step's Timeout (24 hours here) the step fails with "human_task timed out" and the task is listed under MissedAnswer sooner, or choose a different If no response (timeout policy)
Writing {{…}} inside a Lua scriptScripts do not use templates, and the braces are not replacedUse Lua variables such as steps["draft"].result.summary
Returning a plain value from LuaThe step fails with "must return a table"End the script with return { ... }
Reading a step that is not connectedThe template stays as literal {{…}} text, or dry-run reports template_missing_dependencyDraw a line from that step, so it runs first
Using the step's display name in a templateThe value is emptyUse the step's ID. Type {{ and pick a suggestion
Expecting Approve to edit the draftLater steps still see the original textRead the draft from the step that wrote it
Editing after publishing and expecting triggers to changeA schedule or webhook set to Last published or a fixed version keeps running the old copySet its Runs choice to Draft, or publish again
Expecting a failed step to retryA failed step fails the runFix the cause and start a new run. See Run recovery

The workflow as JSON

This is the same workflow as the graph Studio saves. You can paste it with Import, as in step 2. It follows the portable workflow format, so you can also send it through the API or the Platform MCP authoring skills.

{
  "name": "Refund request approval",
  "description": "Summarise a refund request, wait for a person to approve it, then record the decision.",
  "steps": [
    {
      "id": "draft",
      "type": "lua",
      "name": "Draft the summary",
      "script": "local amount = 49\nreturn {\n  customer = \"Dana Lee\",\n  order_id = \"A-1042\",\n  amount = amount,\n  summary = string.format(\"Refund $%.2f to Dana Lee for order A-1042 (item arrived damaged).\", amount)\n}"
    },
    {
      "id": "review",
      "type": "human",
      "name": "Approve the refund",
      "depends_on": ["draft"],
      "task_type": "approval",
      "approver": { "any_member": true, "allow_initiator": true },
      "timeout_s": 86400,
      "task_payload": {
        "title": "Refund request",
        "message": "{{steps.draft.result.summary}}"
      }
    },
    {
      "id": "decision",
      "type": "lua",
      "name": "Record the decision",
      "depends_on": ["review"],
      "script": "local draft = steps[\"draft\"].result\nreturn {\n  approved = steps[\"review\"].result.approved,\n  message = string.format(\"Refund of $%.2f for order %s was approved.\", draft.amount, draft.order_id)\n}"
    }
  ]
}

What each part does:

FieldMeaning
idA unique name for the step. Other steps use it to read this step's output.
typeThe kind of step: lua or human here.
nameA label for people. Never use it in a template.
depends_onThe steps that must finish first. It sets the order.
task_typeapproval gives the reviewer Approve and Reject buttons.
timeout_sHow long the step may wait, in seconds.
task_payloadWhat the reviewer sees. message is the line shown in Command Center. Text values can use templates.

Next steps

Editar esta páginaagentruntime-io/agentruntime-docs