No results

Help CenterCode & APIUsing Code in Your Workflows

Using Code in Your Workflows

Last updated July 24, 2024

Pipedream empowers you to go beyond visual workflow building by letting you incorporate custom code directly into your workflows, adding a layer of flexibility and power to your automations. This article explores how to integrate JavaScript code into your Pipedream workflows, enabling you to perform more complex logic, interact with APIs, and customize your automations to your specific needs.

Adding Code to Your Workflows

Pipedream provides a dedicated "Code" step within your workflow builder, where you can write JavaScript code to add custom logic or interact with external services.

Step 1: Insert a Code Step

  • Workflow Builder: In your workflow, click the "+" button to add a new step.
  • Select "Code": In the list of options, choose the "Code" step. This will insert a code editor within your workflow, where you can write JavaScript code.

Step 2: Write Your JavaScript Code

  • JavaScript Syntax: Pipedream's code editor supports standard JavaScript syntax. You can utilize all the features and libraries of JavaScript.
  • Access Data: The `body` object contains the data from the trigger event, allowing you to access variables and data passed from previous steps.
  • Manipulate Data: Use JavaScript functions like `split()`, `substring()`, `trim()`, `parseInt()`, and `JSON.parse()` to transform data as needed.
  • Access External Services: Use APIs to interact with external applications and services. Pipedream provides a built-in `fetch()` function for making HTTP requests.

Step 3: Return Data and Variables

  • Output: Code steps can return data or variables to be used in subsequent steps.
  • Example:
Was this article helpful?