Docs

Events & Triggers

Trigger functions from queue messages, storage events, and cron schedules.

Functions can be triggered automatically by events — a message in a queue, a file uploaded to storage, or a cron schedule.

Queue Triggers

The most common trigger. One message = one function invocation:

// alien.ts
const tasks = new alien.Queue("tasks").build()

const worker = new alien.Function("worker")
  .trigger({ type: "queue", queue: tasks.ref() })
  .build()
// worker code
import { onQueueMessage } from "@alienplatform/sdk"

onQueueMessage("tasks", async (message) => {
  console.log(message.payload)
  // auto-acknowledged on success, re-delivered on failure
})

Storage Triggers

React to objects being created or deleted:

import { onStorageEvent } from "@alienplatform/sdk"

onStorageEvent("uploads", async (event) => {
  console.log(event.type, event.key)  // "created", "photos/image.jpg"
})

Cron Triggers

const cleanup = new alien.Function("cleanup")
  .trigger({ type: "schedule", cron: "0 0 * * *" })  // daily at midnight
  .build()

Multiple Triggers

A function can have multiple triggers of different types. For example, process queue messages during the day and run a cleanup on a schedule:

const worker = new alien.Function("worker")
  .trigger({ type: "queue", queue: tasks.ref() })
  .trigger({ type: "schedule", cron: "0 0 * * *" })
  .build()

Each trigger independently invokes the function. Note: a function can consume from at most one queue, but can combine a queue trigger with storage or cron triggers.

Platform Support

TriggerAWSGCPAzure
QueueSQS → LambdaPub/Sub → Cloud RunService Bus + KEDA
StorageS3 notificationsGCS notificationsDapr blob storage binding
CronEventBridgeCloud SchedulerDapr cron binding

On this page