Skip to content

Scripts

Scripts let you keep a small piece of code and run it again whenever you need it. A script is JavaScript that runs deterministically in a sandbox: same input, same behaviour, no model call. Use one when a task is better expressed as a few lines of code than as an agent’s instructions — tag records, reshape data, call an allowed API, or emit a value for something else to consume.

Scripts can run on demand, on a schedule, or in response to a platform event.

A script is a workflow with a single code step. The Scripts surface is just a focused editor for that one code step: it gives you a name, a code editor, a trigger, and a Run button, and hides the rest of the workflow machinery you do not need for one block of code.

Because a script is a workflow underneath, everything that applies to workflows applies to scripts:

  • Each run is an execution tracked in the execution history.
  • Scripts support the same three trigger types — manual, event, and schedule.
  • A script can be assigned to a project so it sits alongside the workflows and other parts of the same feature.

The practical difference is authoring. If you want one deterministic block of code, create a script. If you want a multi-step process with agent actions, approvals, or branching, create a workflow and add a code step where you need exact logic.

The Scripts page in the sidebar lists every script in your organisation as a grid of cards. Each card shows the script’s name, its description, whether it is Enabled or Disabled, and how it is triggered (Manual, On event, or On schedule). Click a card to open the editor.

An empty library shows a prompt to create your first script.

  1. Open the Scripts page

    Sign in to team.sprigr.com and click Scripts in the sidebar, then click New Script.

  2. Name it and pick who it runs as

    Enter a Name and an optional Description. Then choose the agent under Runs as. The script runs in that agent’s tool context, so it can reach the same integrations and data that agent can. Every script needs a host agent — the code executes inside the agent’s sandbox.

  3. Write the code

    The code is an async arrow function. Whatever it returns becomes the run’s output:

    async () => {
    // context.trigger holds whatever started this run
    // (the manual input, event payload, or schedule tick).
    // Injected helpers reach your data and allowed endpoints.
    console.log('Hello from my script');
    return { ok: true };
    }

    The editor is JavaScript only. It runs in the sandbox with no raw network access — outbound HTTP calls go through your organisation’s allowed domains.

  4. Create it

    Click Create Script. You land on the script’s editor page, ready to run or refine it.

New scripts default to a manual trigger. See Triggers below to fire on a schedule or an event.

The script detail page is a single-code-step editor:

  • Rename by editing the title inline. The slug and trigger type are shown underneath.
  • Runs as lets you change the host agent.
  • The Code (JavaScript) editor holds the async-arrow body.
  • Save persists your changes. Run now saves the current code first, then starts an execution so Run always exercises exactly what is on screen.
  • Enabled / Disabled toggles whether the script’s triggers are live. A disabled script does not fire on its schedule or event, but you can still open it and use Run now.
  • Delete removes the script (this also removes its execution history and cannot be undone).

The editor has an Ask AI panel. Open it, pick an action, describe what you want in plain English, and press Go:

  • Generate — write new code from a description.
  • Edit code — change the code you already have.
  • Explain — get a plain-English explanation of the current code.

For Generate and Edit, the suggested code drops straight into the editor with Accept and Discard buttons so you can keep or revert it before saving.

A script starts the same three ways a workflow does. Set the trigger on the script and enable it:

  • Manual — runs only when you click Run now in the editor, or when it is started explicitly (for example, by an agent). This is the default for a new script.
  • On schedule — runs on a recurring cron schedule (for example, every Monday at 9am). Scheduled runs cannot fire more often than every 15 minutes.
  • On event — runs automatically when a matching platform event occurs, such as an event from a connected integration or a marketplace app.

Every time a script runs it creates an execution, exactly like a workflow run.

  • Run now shows the result inline in the editor: the final Status (such as completed or failed), the returned value rendered as JSON, and any error. If a run is still going after 30 seconds, the editor stops waiting and points you to the execution history.
  • The returned value from your async arrow is the run output. Anything printed with console.log is captured as part of the run.
  • Past runs live in the execution history alongside your workflow executions, where you can review their status and step results. See Workflow Execution for how to monitor and troubleshoot runs.

Managing scripts with an agent or over MCP

Section titled “Managing scripts with an agent or over MCP”

You do not have to open the portal to work with scripts. Any agent with the manage_team capability — and any external tool connected over MCP — can manage them:

  • create_script — save reusable code as a script. Pass a name, the code (a bare async-arrow string like async () => { return { total: 126 }; }), and the agentId it runs as. It defaults to a manual trigger; pass triggerType and triggerConfig to fire on a schedule or event.
  • list_scripts — list the saved scripts so you can find one to run or edit.

Because a script is a workflow with mode: "script", the same code can also be created through create_workflow by passing mode: "script" and a single code step. The script-named tools are the ergonomic shortcut.

  • Steps & Gates — How code steps behave inside a full workflow.
  • Workflow Execution — Monitor runs and review execution history.
  • Projects — Group a script with the workflows it works alongside.
  • Webhook Scripts — Run code, in JavaScript or Python, when an inbound webhook fires.