Skip to main content
The Custom Code app lets you embed JavaScript (Node.js) or Python functions inside any automation. Reach for it when YAML instructions get awkward: complex transforms, regex parsing, signature computation, anything that’s faster to write as a few lines of code. This page is the practical “how do I add it to my workspace” guide. For the in-depth reference (limits, libraries, advanced examples) see Custom Code in the Apps Marketplace.

When to use it

Custom Code runs inside Prisme.ai’s runtime sandbox with CPU/memory/time limits and a curated allowlist of libraries. It’s not a place to spin up long-running processes or shell commands.

Step 1: Install the Custom Code app in your workspace

  1. Open your workspace in Builder.
  2. Go to Imports in the left navigation.
  3. Click Install an App.
  4. Search for Custom Code and install it.
Once installed, the app exposes a Custom Code.run instruction you can use anywhere in your automations, plus a configuration panel where you declare your functions. Builder Imports section expanded with Custom Code installed

Step 2: Declare a function

Open the Custom Code app’s Configure panel. You’ll see a functions map. Each entry is one named function with three pieces: Equivalent YAML (what you’d see if you edit the import directly):
Python equivalent (only the body changes):
Custom Code app configuration with the functions explorer on the left and the simplifyDocument function open in the Monaco editor on the right
Use the right module for the right job. If your code is “store a value” or “fetch a secret”, use the Collections or Secrets modules instead; they’re faster and audited.

Step 3: Call the function from an automation

Use the Custom Code.run instruction. Pass the function name, the parameters object, and capture the return value via output:
The instruction’s parameters object must match the schema you declared in step 2. Anything you return from the function becomes the value of the output variable.

Inline Python (no app config required)

The Custom Code.run instruction also accepts an inline code field for Python only, handy for one-shot logic you don’t want to register globally:

Step 4: Handle errors

Custom Code raises just like any other instruction. Use onError to control the failure path:
Wrap defensive logic in a try/catch block at the YAML level if you need to recover gracefully:

Step 5: Debug

When something misbehaves:
  1. Open Activity for the automation; every Custom Code.run call is logged with its inputs and the returned value (or error stack).
  2. Add console.log(...) (Node.js) or print(...) (Python) inside the function. Output is captured in the activity log.
  3. If a library you expected isn’t available, check with your platform admin; the allowed list is configured per organization.
Activity tab showing recent runs of process-document and the Custom Code app, with one row expanded to reveal the JSON payload

Common patterns

Limits and constraints

  • Execution time: capped per call; long-running jobs should be broken into automations or moved to a dedicated worker.
  • Memory & CPU: bounded; don’t try to process gigabytes of data inline.
  • Network: outbound HTTP follows the platform’s network policy. Prefer the fetch instruction at the YAML level for clarity and observability.
  • Filesystem: sandboxed; no persistent local files. Use Collections or the Files API for storage.
  • Libraries: only the libraries explicitly allowed by your organization are available. Check the Custom Code reference for the default list.

Next steps

Custom Code reference

Full reference: libraries, deeper examples, security considerations.

Automations

The instruction set Custom Code plugs into.

Custom tools for agents

Wrap your automation as a tool an agent can call.

Secrets module

Inject API keys and tokens without hard-coding them.