Iii iii-custom-triggers
install
source · Clone the upstream repo
git clone https://github.com/iii-hq/iii
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/iii-hq/iii "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/iii-custom-triggers" ~/.claude/skills/iii-hq-iii-iii-custom-triggers && rm -rf "$T"
manifest:
skills/iii-custom-triggers/SKILL.mdsource content
Custom Triggers
Comparable to: Custom event adapters, webhook receivers
Key Concepts
Use the concepts below when they fit the task. Not every custom trigger needs all of them.
- registerTriggerType(id, handler) defines a new trigger type with
andregisterTrigger
callbacksunregisterTrigger - The handler receives a TriggerConfig containing
,id
, andfunction_idconfig - When the external event fires, call
to invoke the registered functioniii.trigger({ function_id, payload: event }) - unregisterTriggerType cleans up when the trigger type is no longer needed
- Do not reuse built-in trigger type names:
,http
,cron
,durable:subscriber
,state
,streamsubscribe
Architecture
External event source (webhook, file watcher, IoT, CDC, etc.) → Custom trigger handler (registerTriggerType) → iii.trigger({ function_id, payload: event }) → Registered function processes the event
iii Primitives Used
| Primitive | Purpose |
|---|---|
| Define a new trigger type with lifecycle hooks |
| Clean up a custom trigger type |
| Configuration passed to the trigger handler |
| Fire the registered function when the event occurs |
Reference Implementation
See ../references/custom-triggers.js for the full working example — a custom trigger type that listens for external events and routes them to registered functions.
Also available in Python: ../references/custom-triggers.py
Also available in Rust: ../references/custom-triggers.rs
Common Patterns
Code using this pattern commonly includes, when relevant:
— worker initializationregisterWorker(url, { workerName })
— define the custom triggerregisterTriggerType(id, { registerTrigger, unregisterTrigger })
— called by iii when a function subscribes to this trigger typeregisterTrigger(config)
— called by iii when a function unsubscribesunregisterTrigger(config)
— fire the target functioniii.trigger({ function_id: config.function_id, payload: eventPayload })- Cleanup logic in
(close connections, remove listeners, clear intervals)unregisterTrigger
— structured loggingconst logger = new Logger()
Adapting This Pattern
Use the adaptations below when they apply to the task.
- Choose a unique trigger type name that describes your event source (e.g.
,file-watcher
,mqtt
)db-cdc - In
, start the listener (open socket, poll endpoint, subscribe to topic)registerTrigger - In
, tear down the listener to avoid resource leaksunregisterTrigger - Store active listeners in a map keyed by
for clean unregistrationconfig.id - Pass relevant event data in the payload when calling
iii.trigger({ function_id, payload: event })
Pattern Boundaries
- If the task uses built-in HTTP routes, prefer
.iii-http-endpoints - If the task uses built-in cron schedules, prefer
.iii-cron-scheduling - If the task uses built-in queue triggers, prefer
.iii-queue-processing - Stay with
when iii has no built-in trigger type for the event source.iii-custom-triggers
When to Use
- Use this skill when the task is primarily about
in the iii engine.iii-custom-triggers - Triggers when the request directly asks for this pattern or an equivalent implementation.
Boundaries
- Never use this skill as a generic fallback for unrelated tasks.
- You must not apply this skill when a more specific iii skill is a better fit.
- Always verify environment and safety constraints before applying examples from this skill.