Workflows Beta

Stelace Workflows are the fastest way to run automated logic empowering Events, in a serverless fashion.

Events trigger your appropriate Workflows, meaning JavaScript logic is executed on our servers, as it would be with a service like Zapier or AWS Lambda, but natively leveraging all Stelace API endpoints and external systems as well.

Here is a working example taken from Heroes starter kit. Stelace team gets notified via Slack in real-time when a visitor flags any hero:

Heroes Demo Hero flag notification on Slack

// Sample Workflow object
{
  name: "flagVisitorHero",
  description: "Flags hero using custom Event",
  event: "flag_hero", // custom Event name triggering this Workflow
  computed: {
    // Using simple JavaScript expressions and lodash
    shouldFlag: "!asset.platformData.createdByStelace && _.get(asset, 'metadata.flags', 0) > 0"
  },
  run: [
    {
      name: "flag",
      description: "Deactivates Hero Asset if already flagged before.",
      endpointMethod: "PATCH",
      endpointUri: "/assets/${asset.id}",
      endpointPayload: {
        active: "computed.shouldFlag ? false : undefined",
        metadata: {
          flags: "_.get(asset, 'metadata.flags', 0) + 1"
        }
      }
    },
    {
      name: "flagSlackNotif",
      description: "Notify Team on Slack when some hero is flagged.",
      endpointMethod: "POST",
      skip: "!env.SLACK_WEBHOOK_URL", // secured environment variables set in Stelace Dashboard
      endpointUri: "${env.SLACK_WEBHOOK_URL}",
      endpointPayload: {
        text: "`${asset.name} [${asset.id}] flagged on <heroes.demo.stelace.com|live demo>.`"
      }
    }
  ]
}

Workflows are a beta feature currently available in early access.

Please get in touch if you feel like joining our beta testers, or just have a look at our API reference API.