Compass Docs
  • Collections
    • ๐Ÿš€Trending
    • ๐ŸŒฑMinting Now
    • ๐Ÿ“ƒCollection Watchlists
    • ๐Ÿ–ผ๏ธToken Window
    • โ†”๏ธCollection Activity
    • ๐Ÿ†Collection Profit Leaderboard
    • ๐ŸŽจCollection Tokens
    • ๐Ÿ‹Collection Top Holders
    • โ›๏ธCollection Mint History
    • ๐Ÿ”Collection Analytics
  • Wallets
    • ๐Ÿš€Getting started with Wallets
    • ๐Ÿ‘›Wallet overview
    • ๐Ÿ”Wallet Activity with Filtering
    • ๐Ÿ™‹Own Wallets
    • ๐ŸฅžFlips
    • ๐Ÿ‘ฅWallet Groups
    • ๐Ÿ”—Related Wallets
  • Pulse
    • ๐Ÿฅ‡Profit leaderboard
    • ๐Ÿ“ˆCompass Pulse
  • Alerts
    • โฐGetting Started with Alerts
  • Automations
    • ๐Ÿš€Getting Started with Automations
    • ๐Ÿ’ฐWallets
    • ๐Ÿ“˜Key Terms in Automations
    • ๐Ÿ”€Inputs/Outputs
    • ๐ŸงชTesting Automations
    • ๐Ÿš€Set Up Your First Listing Alert
    • ๐Ÿ”ซTriggers
      • Token Received
      • Token Sent
      • Token Bought
      • Token Sold
      • Token Minted
      • Webhook
      • Repeat
      • Token Listed
      • Telegram
      • Trigger Advanced Settings
    • ๐Ÿ’ณPricing
    • โšกCustom Actions
      • @compass/http
      • @compass/api
      • @compass/cache
      • @compass/utils
      • @compass/variables
      • @compass/wallet
Powered by GitBook
On this page
  • Getting Started with Custom Actions
  • Structure of Actions
  • The Script
  • Example
  1. Automations

Custom Actions

PreviousPricingNext@compass/http

Last updated 1 year ago

Getting Started with Custom Actions

Custom Actions are a powerful feature of our automation suite, allowing you to write and execute your own JavaScript code within automations. You can even share these Custom Actions with others!

Structure of Actions

A Custom Action comprises three parts:

  • Input: The data that you want to pass into the action. This is defined via the UI.

  • Output: The data that the action returns. This is also defined via the UI.

  • Script: The JavaScript code that processes the input and generates the output.

To learn more about Inputs and Outputs, see .

The Script

Your script will run inside a V8 sandbox environment, which supports ES2020 syntax and exposes standard JavaScript APIs (e.g., Math, String, Array, etc.).

Packages

In addition to vanilla JavaScript APIs, you can also import and use certain packages within your scripts. Currently, the following packages are available:

  • - Simplified HTTP request functionalities

  • - Utilities to work with wallets

  • - Query the Compass API easily

  • - Store and retrieve temporary data to be reused across automations

  • - Utility functions

Click on the links to access detailed documentation for each package.

Scripting Environment

The sandbox environment imports your script as a module, and it should export a function as default. This function receives a context object as the first argument. The context.inputs property contains the input values passed to the action, as defined by the inputs.

Your function (which can be asynchronous) should return an object with keys that match those defined in the outputs.

Example

Here is a basic example of a script that makes a GET request:

import http from "@compass/http";

export default async function(context) {
    const data = await http.get(context.inputs.url);

    return {
        responseData: data,
    }
}

In this script, the url is passed as an input, and the resulting data is returned as an items output.

Custom Actions provide an incredibly flexible way to extend the capabilities of our automation suite, and we're excited to see what you'll build with them!

โšก
this article
@compass/http
@compass/wallet
@compass/api
@compass/cache
@compass/utils