Actions
Actions make Fostrom programmable. An Action is a small piece of JavaScript that runs in response to a trigger and produces side effects—such as sending messages to devices or triggering webhooks. By reacting to real‑time events, Actions let you close the loop between incoming telemetry and outbound control, turning a telemetry pipeline into an autonomous system.
Key concepts
Currently, actions can be triggered by incoming Message Schema whose Direction is defined as Inbound or Both. Additional triggers, including device state changes such as online/offline, real‑time aggregations, and analytical pipeline outputs, are coming soon. Outbound messages produced by Actions are queued to each device’s mailbox. Each device processes its mailbox sequentially and at its own pace, which preserves general ordering and protects devices from overload.
How Actions run
Actions run in a sandboxed, Javy‑based WebAssembly environment with additional restrictions. Execution time is limited to 500 ms per run, with overruns terminated. Node.js and npm modules are not available, timers like setTimeout/setInterval are unavailable, and network access from the runtime is not permitted—external effects are performed through Fostrom’s provided APIs.
You write JavaScript. The runtime provides the triggering message context and helper APIs under the fostrom. namespace. Logging via console.debug(), console.log(), console.warn(), and console.error() is captured to Action logs. The in‑app editor includes linting, code completion, and guided autocompletion for Fostrom resources such as devices, packet schemas, tags, and webhooks.
Effects (what Actions can do)
- Send a message to a specific device using a Message Schema.
- Broadcast a message to all devices matching a tag, respecting each device’s sequential mailbox.
- Trigger a pre‑configured webhook (payload shape depends on content type).
Authoring, testing, and deployment
You create an Action by choosing its trigger - an existing Message Schema set to Inbound or Both, then author JavaScript in the code editor. Before deployment, you must test the Action by selecting a device and providing the trigger payload (either auto‑generated randomized values or manual entry; skip this if the schema has no fields). The test shows a status of Pending, Error, or Successful and provides an output log with execution details. Deployment is enabled only after a successful test; once deployed, new triggers run the latest code. You can review execution details and outputs in Action Logs.
Why Actions
- Respond to real‑world events in real time.
- Enforce data quality via schemas while safely fanning out control signals through device mailboxes.
- Build workflows entirely in the cloud without frequent firmware updates.
What’s next
- More triggers: device online/offline events, time‑windowed aggregations (e.g., 5‑minute averages), and analytical pipeline flows (stats and AI).
- Improvements to editor and authoring experience.
- Enhanced test controls and logs.