Use TypeScript in an Evaluate block

You can use TypeScript to process and manipulate data in Evaluate, Condition, and If blocks in your flows. For example, you might use TypeScript to format a timestamp, check a response for errors, or select an item from a list.

Recipe

The following recipe describes how to use TypeScript with an Evaluate block to select a random item from a list:

  1. Create a flow module and add an HTTP Request block. For this example, send a GET request to https://openlibrary.org/subjects/love.json?limit=5.

    This gets a list of five book titles.

  2. Connect an Evaluate block to the HTTP Request block’s Success port.

  3. In the Evaluate block, name the variable items and set it to body.works.

  4. Enter the following TypeScript in the Evaluate block to select a random title from the response:

    items[Math.floor(Math.random() * items.length)].title
    
  5. Run the flow and click the Evaluate block’s Result output port to see the selected title.

Try it out

To see this recipe’s completed flow, check out Cookbook: Use TypeScript to select a random item from a list. You can also clone this flow to your workspace to experiment with it.

Last modified: 2025/09/09


Postmanaut Cooper jumping over crystal ball. Illustration.