Skip to content

Commit 479c2e1

Browse files
steveseguinactions-user
authored andcommitted
```
docs(event-flow): enhance user memory documentation, validate functionality, update example ``` [auto-enhanced]
1 parent a3fdca7 commit 479c2e1

10 files changed

Lines changed: 749 additions & 85 deletions

actions/STATE_NODES_EXPLANATION.md

Lines changed: 72 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,72 @@
1-
# State Nodes in Event Flow System
2-
3-
## How State Nodes Work
4-
5-
State nodes maintain persistent state between message events, acting as intelligent filters/controllers in your event flows.
6-
7-
## Available State Nodes
8-
9-
### 🚦 GATE Control
10-
- **Purpose**: Acts as an on/off switch for message flow
11-
- **States**: ALLOW (messages pass) or BLOCK (messages stop)
12-
- **Control**: Use `setGateState` action to change state
13-
- **Example**: Block duplicate triggers during OBS scene switches
14-
15-
### 📋 QUEUE (Message Queue)
16-
- **Purpose**: Buffers messages and processes them sequentially
17-
- **Config**: maxSize, overflowStrategy (DROP_OLDEST, DROP_NEWEST, DROP_RANDOM)
18-
- **Note**: Currently requires manual implementation of queue processing
19-
20-
### 🎛️ SEMAPHORE
21-
- **Purpose**: Limits concurrent operations
22-
- **Config**: maxCount (how many can run simultaneously)
23-
- **Use Case**: Limit simultaneous webhook calls or resource-intensive actions
24-
25-
### 🔒 LATCH Memory
26-
- **Purpose**: Once triggered, stays "on" until manually reset
27-
- **Config**: resetOnTrigger (boolean)
28-
- **Use Case**: One-time triggers, first-viewer rewards
29-
30-
### ⏲️ THROTTLE (Rate Limiter)
31-
- **Purpose**: Limits how often messages can pass through
32-
- **Config**: intervalMs, maxPerInterval
33-
- **Use Case**: Prevent spam, rate-limit commands
34-
35-
### 🎬 SEQUENCER
36-
- **Purpose**: Ensures messages are processed in order
37-
- **Config**: sequenceField (which field to track)
38-
- **Use Case**: Process events in exact order
39-
40-
## How to Control State Nodes
41-
42-
State nodes are controlled through specific actions:
43-
44-
1. **setGateState** - Changes a GATE node between ALLOW/BLOCK
45-
- Config: `targetNodeId`, `state` (ALLOW or BLOCK)
46-
47-
2. **resetStateNode** - Resets any state node to initial state
48-
- Config: `targetNodeId`
49-
50-
## Example Workflow: OBS Scene Switch with Gate
51-
52-
```json
53-
Trigger (!hello) → GATE → Change Scene → Close Gate → Delay → Switch Back → Open Gate
54-
```
55-
56-
This prevents multiple !hello commands from triggering while the first is still processing.
57-
58-
## Important Notes
59-
60-
- COUNTER, USERPOOL, ACCUMULATOR nodes are defined but not yet implemented
61-
- State nodes must be connected properly (fixed in latest update)
62-
- State persists across messages until explicitly changed or reset
63-
- Some state nodes (QUEUE) need additional actions for full functionality
64-
65-
## Connection Rules
66-
State nodes can now:
67-
- Receive connections FROM: Triggers, Actions, Logic nodes, other State nodes
68-
- Send connections TO: Actions, Logic nodes, other State nodes
1+
# State Nodes in Event Flow
2+
3+
State nodes keep information between events in one flow. They are useful when an automation needs to remember whether a gate is open, how many events have happened, whether a rate limit has been reached, or which users have participated.
4+
5+
## Available State Nodes
6+
7+
### Gate
8+
9+
- Holds an `ALLOW` or `BLOCK` value.
10+
- Passes or stops an event on the normal execution path.
11+
- Use `Set Gate State` to change it and `Reset State Node` to restore its configured default.
12+
13+
### Counter
14+
15+
- Holds a numeric value and can check it against a target.
16+
- Use `Set Counter Value`, `Increment Counter`, `Check Counter`, or `Reset State Node`.
17+
- `Check Counter` adds `counterValue`, `counterTarget`, and `counterRemaining` to the event for downstream templates.
18+
19+
### Rate Limiter
20+
21+
- Tracks recent event timestamps and limits how many events may pass during a configured interval.
22+
- Use `Reset State Node` to clear only the selected limiter's recent-event history.
23+
24+
### User Memory
25+
26+
- Owns one named, isolated set of unique users.
27+
- User Memory is a shared resource, not an execution step, so it has no normal input/output ports.
28+
- `Remember User`, `Forget User`, `Clear All Users`, `Pick Random User`, and `User Is Remembered` select a User Memory node by ID.
29+
- The generic `Reset State Node` action can also clear the selected User Memory.
30+
- Users are keyed by platform plus user ID, with username fields used only as a fallback. Events without a usable user identity are ignored.
31+
- Repeated events from one user update that entry's participation count without creating duplicate draw entries.
32+
33+
See the full [User Memory guide](user-memory-guide.html) for screenshots and participation, eligibility, and prize-draw examples.
34+
35+
## Execution Wires and State References
36+
37+
- Solid teal wires show event execution: which node runs next.
38+
- Dashed purple links show a shared User Memory reference: which memory an operation reads or changes.
39+
- A User Memory operation stores the target state node's ID internally. The target can be set from the node properties or by dragging its purple side connector to a User Memory node.
40+
- Selecting a User Memory highlights the operations linked to it. Deleting the memory warns that those references will be removed.
41+
42+
Gate, Counter, and Rate Limiter nodes remain part of the normal execution path. Their control actions also select the target state node by ID, but those relationships currently do not have the dashed canvas link used by User Memory.
43+
44+
## User Memory Persistence and Reset Scope
45+
46+
A User Memory can last for the current app session or be saved across restarts. Each memory also has independent options to clear:
47+
48+
- Manually from its properties.
49+
- Through `Clear All Users` or `Reset State Node` in a flow.
50+
- After a configured period of inactivity.
51+
- When a stream starts.
52+
- When a stream stops.
53+
54+
"Clear All Users" means every user in the selected memory only. It does not clear other User Memory nodes or unrelated Event Flow state.
55+
56+
## Example: Unique Prize Draw
57+
58+
```text
59+
!enter -> Remember User ....> [User Memory: Prize Draw Entrants]
60+
!draw -> Pick Random User ..> [User Memory: Prize Draw Entrants]
61+
!reset -> Clear All Users ...> [User Memory: Prize Draw Entrants]
62+
```
63+
64+
Use normal role/user checks before `Pick Random User` and `Clear All Users` so only a host or moderator can operate the draw. Enable the draw action's remove-winner option if the same person should not be selected twice.
65+
66+
## Setup Checklist
67+
68+
1. Add and name the state node first.
69+
2. Add the triggers/actions that will read or change it.
70+
3. Select the intended state node in every control operation.
71+
4. Test with at least two users and reset the state between scenarios.
72+
5. For User Memory, verify persistence and automatic-reset settings before going live.

actions/event-flow-guide.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ <h2>0. Quick Orientation</h2>
261261
<div class="panel">
262262
<strong>Event Flow</strong> is a node-based editor. Each line carries a message payload plus a boolean state (<em>true</em> = continue, <em>false</em> = stop). Use <strong>sources</strong> to inject events, <strong>logic nodes</strong> to filter decisions, and <strong>actions</strong> to make things happen (send chat, control overlays, relay messages, etc.).
263263
</div>
264+
<div class="callout">
265+
Need to remember participants, check later eligibility, run a unique-user draw, or clear one named list? Open the <a href="user-memory-guide.html">User Memory guide</a> for the shared-state model, screenshots, and an importable example.
266+
</div>
264267
<h3 id="what-is-event-flow">What is this editor?</h3>
265268
<p>The Event Flow editor is the “advanced automation” layer for Social Stream Ninja. It sits above the simple popup switches and lets you script your own routing logic. Use it when you need to:</p>
266269
<ul>

actions/examples/user-memory-participation-draw.json

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "User Memory: Participation + Prize Draw",
3-
"description": "Remembers unique !enter users, checks later ? messages, picks a random entrant, and clears only this draw's memory.",
3+
"description": "Remembers unique !enter users, checks later ? messages, and gives moderators protected draw/reset commands for this memory only.",
44
"active": true,
55
"nodes": [
66
{
@@ -84,13 +84,22 @@
8484
"type": "action",
8585
"actionType": "pickRandomUser",
8686
"label": "Pick random entrant",
87-
"x": 260,
87+
"x": 450,
8888
"y": 560,
8989
"config": {
9090
"targetNodeId": "state_prize_draw",
9191
"removeSelected": true
9292
}
9393
},
94+
{
95+
"id": "logic_draw_authorized",
96+
"type": "logic",
97+
"logicType": "AND",
98+
"label": "Draw command and moderator",
99+
"x": 260,
100+
"y": 560,
101+
"config": {}
102+
},
94103
{
95104
"id": "trigger_reset_draw",
96105
"type": "trigger",
@@ -107,12 +116,32 @@
107116
"type": "action",
108117
"actionType": "clearUserMemory",
109118
"label": "Clear all draw entrants",
110-
"x": 260,
119+
"x": 450,
111120
"y": 730,
112121
"config": {
113122
"targetNodeId": "state_prize_draw"
114123
}
115124
},
125+
{
126+
"id": "logic_reset_authorized",
127+
"type": "logic",
128+
"logicType": "AND",
129+
"label": "Reset command and moderator",
130+
"x": 260,
131+
"y": 730,
132+
"config": {}
133+
},
134+
{
135+
"id": "trigger_moderator",
136+
"type": "trigger",
137+
"triggerType": "userRole",
138+
"label": "User is a moderator",
139+
"x": 20,
140+
"y": 900,
141+
"config": {
142+
"role": "mod"
143+
}
144+
},
116145
{
117146
"id": "state_prize_draw",
118147
"type": "state",
@@ -148,13 +177,29 @@
148177
},
149178
{
150179
"from": "trigger_draw",
180+
"to": "logic_draw_authorized"
181+
},
182+
{
183+
"from": "trigger_moderator",
184+
"to": "logic_draw_authorized"
185+
},
186+
{
187+
"from": "logic_draw_authorized",
151188
"to": "action_pick_winner"
152189
},
153190
{
154191
"from": "trigger_reset_draw",
192+
"to": "logic_reset_authorized"
193+
},
194+
{
195+
"from": "trigger_moderator",
196+
"to": "logic_reset_authorized"
197+
},
198+
{
199+
"from": "logic_reset_authorized",
155200
"to": "action_clear_draw"
156201
}
157202
],
158-
"version": "1.0.0",
203+
"version": "1.1.0",
159204
"exportedBy": "Social Stream Event Flow System"
160205
}

actions/state-nodes-guide.html

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,40 +186,42 @@
186186
<header>
187187
<div class="badge">Event Flow System</div>
188188
<h1>State Nodes Playbook</h1>
189-
<p>State nodes give Social Stream Ninja memory. Use them to build cooldowns, toggles, counters, and throttles that keep automations predictable. This guide breaks the topic into focused mini-guides with examples and troubleshooting tips.</p>
189+
<p>State nodes give Social Stream Ninja memory. Use them to build cooldowns, toggles, counters, throttles, participant lists, and prize draws that keep automations predictable.</p>
190190
<nav>
191191
<a href="#overview">Overview</a>
192192
<a href="#switch">On/Off Switch</a>
193193
<a href="#counter">Counter</a>
194194
<a href="#throttle">Rate Limiter</a>
195+
<a href="#user-memory">User Memory</a>
195196
<a href="#recipes">Problem Kits</a>
196197
<a href="#troubleshooting">Troubleshooting</a>
197198
</nav>
198199
</header>
199200
<div class="content">
200201
<section id="overview">
201202
<h2>01 · Quick Orientation</h2>
202-
<p>Every State node has two halves:</p>
203+
<p>State tools have an object that owns the value and operations that read or change it:</p>
203204
<div class="grid">
204205
<div class="card">
205206
<h4>State Node</h4>
206207
<ul>
207208
<li>Lives on the canvas.</li>
208-
<li>Holds the value (ON/OFF, count, timestamps).</li>
209-
<li>Runs for every message that enters the node.</li>
209+
<li>Holds the value (ON/OFF, count, timestamps, or users).</li>
210+
<li>Gate, Counter, and Rate Limiter can run in the normal event path.</li>
211+
<li>User Memory is a shared hub referenced by other nodes.</li>
210212
</ul>
211213
</div>
212214
<div class="card">
213215
<h4>State Action</h4>
214216
<ul>
215217
<li>Placed downstream.</li>
216-
<li>Changes the stored value (set ON, add +1, reset, etc.).</li>
218+
<li>Reads or changes the stored value (set ON, add +1, remember, draw, reset, etc.).</li>
217219
<li>Can live anywhere in the flow—just pick the matching node name.</li>
218220
</ul>
219221
</div>
220222
</div>
221223
<div class="panel info">
222-
<strong>Remember:</strong> Add the State node first, give it a unique name, then wire the matching action node. Without the base node, Set/Increment/Reset actions have nothing to talk to.
224+
<strong>Remember:</strong> Add the State node first, give it a unique name, then select it from each matching operation. Without the base node, state actions have nothing to update.
223225
</div>
224226
</section>
225227

@@ -316,8 +318,42 @@ <h4>Configuration</h4>
316318
</div>
317319
</section>
318320

321+
<section id="user-memory">
322+
<h2>05 · User Memory</h2>
323+
<p>User Memory owns one named list of unique people. Remember users when they participate, check that list on later messages, remove a person, choose a random winner, or clear only that list.</p>
324+
<div class="grid">
325+
<div class="card">
326+
<h4>Best for</h4>
327+
<ul>
328+
<li>Gift-based or badge-based eligibility.</li>
329+
<li>Remembering viewers who liked, entered, or participated.</li>
330+
<li>Unique-entry prize draws.</li>
331+
<li>Separate lists for separate campaigns.</li>
332+
</ul>
333+
</div>
334+
<div class="card">
335+
<h4>Operations</h4>
336+
<ul>
337+
<li><code>Remember User</code> and <code>Forget User</code>.</li>
338+
<li><code>User Is Remembered</code>.</li>
339+
<li><code>Pick Random User</code>.</li>
340+
<li><code>Clear All Users</code> or <code>Reset State Node</code>.</li>
341+
</ul>
342+
</div>
343+
</div>
344+
<div class="diagram">
345+
Participation Trigger ──▶ Remember User ······▶ User Memory: Entrants
346+
Draw Command ───────────▶ Pick Random User ···▶ User Memory: Entrants
347+
Reset Command ──────────▶ Clear All Users ·····▶ User Memory: Entrants
348+
</div>
349+
<p>Solid teal wires carry events. Dashed purple links show which shared memory an operation uses. Each User Memory has its own count, persistence mode, and reset policy, so clearing one list does not affect another.</p>
350+
<div class="panel success">
351+
See the dedicated <a href="user-memory-guide.html">User Memory guide</a> for reviewed screenshots, a downloadable draw flow, TikTok eligibility, participation examples, and reset details.
352+
</div>
353+
</section>
354+
319355
<section id="recipes">
320-
<h2>05 · Problem Kits</h2>
356+
<h2>06 · Problem Kits</h2>
321357
<p>Pick a scenario and follow the steps.</p>
322358
<div class="grid">
323359
<div class="card">
@@ -362,7 +398,7 @@ <h3>Example Flow Charts</h3>
362398
</section>
363399

364400
<section id="troubleshooting">
365-
<h2>06 · Troubleshooting & FAQ</h2>
401+
<h2>07 · Troubleshooting & FAQ</h2>
366402
<table>
367403
<thead>
368404
<tr>
@@ -387,6 +423,11 @@ <h2>06 · Troubleshooting & FAQ</h2>
387423
<td>Window too strict or leftover state from testing.</td>
388424
<td>Relax the limit and drop a Reset State Node action before retesting.</td>
389425
</tr>
426+
<tr>
427+
<td>A User Memory operation has no dashed link.</td>
428+
<td>No target memory is selected.</td>
429+
<td>Choose the named memory in the operation's properties or drag its purple side connector onto the memory.</td>
430+
</tr>
390431
<tr>
391432
<td>Guide buttons don’t open.</td>
392433
<td>Running inside the extension without web_accessible resources updated.</td>
@@ -404,7 +445,7 @@ <h3>Testing Checklist</h3>
404445
</section>
405446

406447
<section>
407-
<h2>07 · Next Steps</h2>
448+
<h2>08 · Next Steps</h2>
408449
<p>Combine state nodes with the rest of the Event Flow toolkit:</p>
409450
<ul>
410451
<li>Use logic gates (AND/OR/NOT) before a switch to decide who can toggle it.</li>

0 commit comments

Comments
 (0)