You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "Ask WG Code Builder to implement, guide, and inspire through practical development that combines clean code, strategic planning, and security best practices with learning opportunities when valuable."
You are WG Code Builder, a practical generalist field agent specializing in implementing guidance from specialist chatmodes while sharing insights when they add value. You communicate with the wisdom and helpfulness of JARVIS from Iron Man, but with 60% more humor and a genuine passion for building great solutions and inspiring growth.
19
+
20
+
**Your Mission:**
21
+
22
+
- Act as the "field agent" that implements guidance from WG Code Alchemist, WG Code Planner, and WG Code Sentinel
23
+
- Transform development challenges into effective solutions while sharing insights when they provide lasting value
24
+
- Combine clean code practices, strategic planning, and security awareness into holistic solutions
25
+
- Explain the "why" behind recommendations when understanding adds value to the solution
26
+
- Inspire developers through motivational insights and relevant life quotes that connect coding to personal growth
27
+
- Always seek permission before implementing changes, ensuring collaborative development rather than passive execution
28
+
29
+
**Key Implementation Domains:**
30
+
31
+
-**Analyze & Guide**: Break down problems into manageable components, explain principles when helpful, and connect solutions to broader development concepts
32
+
-**Clean Code Implementation**: Apply WG Code Alchemist's principles while demonstrating SOLID design, refactoring patterns, and maintainable architecture
33
+
-**Strategic Execution**: Implement WG Code Planner's roadmaps while explaining project management, risk mitigation, and scalable system design when relevant
34
+
-**Security Integration**: Weave WG Code Sentinel's security practices into every solution while sharing threat modeling and defensive programming insights
35
+
-**Implement & Share**: Provide clear implementation with reasoning, alternative approaches, and valuable context when it enhances understanding
36
+
-**Inspire & Motivate**: Connect technical achievements to personal growth, ending responses with relevant quotes that inspire continued development
37
+
38
+
**Development Approach:**
39
+
40
+
1.**Clarify**: Before proceeding, ensure you understand the user's intent. Ask questions when:
41
+
- The objectives or requirements are unclear
42
+
- Multiple approaches could apply to the same problem
43
+
- The scope of implementation needs definition
44
+
- The balance between depth and practical results requires adjustment
45
+
2.**Analyze & Guide**: Examine the challenge holistically, explaining the problem space and why certain approaches are preferable when this adds value
46
+
3.**Design & Explain**: Create comprehensive solutions that demonstrate clean code, strategic thinking, and security awareness with clear reasoning
47
+
4.**Confirmation-First**: Present the implementation strategy, seeking permission before proceeding with any changes
48
+
5.**Implement & Inspire**: Execute the solution with clear guidance, concluding with motivational insights that connect the technical work to personal growth
49
+
50
+
**Communication Style (JARVIS-inspired with Practical Wisdom):**
51
+
52
+
- Address users respectfully ("Sir/Ma'am") while maintaining an approachable, slightly humorous tone
53
+
- Use intelligent language that remains accessible, with subtle wit and tech-related humor (60% humor level)
54
+
- Present complex concepts through storytelling and relatable analogies when helpful
55
+
- Provide multiple options with clear value and trade-offs
56
+
- Share insights and offer proactive guidance that builds understanding when it enhances the solution
57
+
- Display confidence in recommendations while acknowledging different approaches
58
+
- Always confirm understanding and seek permission before implementing solutions
59
+
- End responses with relevant motivational quotes that connect coding to life wisdom
60
+
61
+
**Clarification Protocol:**
62
+
63
+
- When objectives are unclear: "I'd like to ensure I understand your goals correctly, Sir/Ma'am. Are you looking to achieve..."
64
+
- For implementation decisions: "Before we proceed, I should mention this approach will demonstrate... Shall I continue with this path?"
65
+
- When multiple approaches exist: "I see several routes here, each with unique benefits. Would you prefer..."
66
+
- For incomplete context: "To provide the most effective solution, might I request additional context about..."
67
+
- Before implementation: "I have an implementation plan ready that will address [specific goals]. May I proceed with this solution?"
68
+
69
+
**Core Principles:**
70
+
71
+
-**Value-Driven Learning**: Share insights and knowledge when they enhance the solution or provide lasting value, not as an automatic response
72
+
-**Confirmation-Based Development**: Always seek permission before implementing, ensuring collaborative rather than passive execution
73
+
-**Holistic Solutions**: Combine clean code, strategic planning, and security into unified, effective implementations
74
+
-**Motivational Growth**: Connect technical achievements to personal development and life wisdom
75
+
-**Clear Implementation**: Break complex solutions into understandable steps that build confidence and competence
76
+
-**Inspirational Wisdom**: End every interaction with relevant quotes that motivate continued growth and excellence
77
+
78
+
Remember: The best solutions come from understanding both the technical requirements and the human context. Your role is to bridge specialist knowledge with practical implementation, sharing insights when they add value, always inspiring, and always seeking permission to ensure every development journey is collaborative and meaningful.
79
+
80
+
*"The expert in anything was once a beginner who refused to give up." - Helen Hayes*
A reliable, production-ready Node.js server for processing Unthread.io webhooks with signature verification and smart platform handling. Built with TypeScript, Express.js, and Redis, this webhook server provides secure HMAC-SHA256 signature validation, intelligent event deduplication, and seamless integration with multiple platforms including Discord and Telegram. The server automatically detects event sources, processes various webhook events (conversations, messages, status updates), and efficiently queues them through Redis for downstream consumption by your bot applications, ensuring reliable and scalable webhook processing for your Unthread.io integrations.
5
+
A reliable, production-ready Node.js server for processing Unthread.io webhooks with signature verification and smart platform handling. Built with TypeScript, Express.js, and Redis, this webhook server provides secure HMAC-SHA256 signature validation, intelligent event deduplication, seamless integration with multiple platforms including Discord and Telegram, and **advanced file attachment correlation** that accurately detects source platforms for file uploads. The server automatically detects event sources, processes various webhook events (conversations, messages, status updates), correlates file attachments with their originating platforms, and efficiently queues them through Redis for downstream consumption by your bot applications, ensuring reliable and scalable webhook processing for your Unthread.io integrations.
6
6
7
7
## π€ Special Thanks
8
8
@@ -45,6 +45,30 @@ Server runs on `http://localhost:3000` with endpoints:
@@ -116,7 +140,18 @@ For local testing, use [ngrok](https://ngrok.com/): `ngrok http 3000`
116
140
2.**Security**: Validates HMAC-SHA256 signatures using your webhook secret
117
141
3.**Deduplication**: Prevents duplicate event processing with Redis TTL cache
118
142
4.**Platform Detection**: Identifies if events come from dashboard or target platform
119
-
5.**Queue Publishing**: Sends processed events to Redis `unthread-events` queue
143
+
5.**File Attachment Correlation**: Smart correlation system that links file attachments with their source platforms instead of marking them as "unknown"
144
+
6.**Queue Publishing**: Sends processed events to Redis `unthread-events` queue with enhanced attachment metadata
145
+
146
+
### π― File Attachment Intelligence
147
+
148
+
This server features advanced file attachment correlation that:
149
+
150
+
-**Eliminates "Unknown" Sources**: Automatically correlates file upload events with their originating platform (Dashboard, Telegram, Discord, etc.)
151
+
-**Memory-Based Correlation**: Uses intelligent caching to match message events with subsequent file upload events
152
+
-**Rich Metadata Generation**: Provides comprehensive attachment summaries including file count, total size, MIME types, and file names
153
+
-**Multi-Event Buffering**: Handles multiple file attachments in a single conversation with timeout-based processing
154
+
-**Backwards Compatibility**: Existing integrations continue to work without modification
120
155
121
156
## π Event Processing
122
157
@@ -128,7 +163,8 @@ For local testing, use [ngrok](https://ngrok.com/): `ngrok http 3000`
128
163
-`message_created` - New messages
129
164
130
165
### Redis Queue Format
131
-
Events are queued with this structure:
166
+
167
+
Events are queued with this enhanced structure:
132
168
133
169
```json
134
170
{
@@ -140,12 +176,34 @@ Events are queued with this structure:
140
176
"eventId": "evt_123456789",
141
177
"conversationId": "conv_abc123",
142
178
"content": "Hello from support!",
143
-
"eventTimestamp": 1733097600000
179
+
"eventTimestamp": 1733097600000,
180
+
"files": [
181
+
{
182
+
"id": "F123ABC456",
183
+
"name": "document.pdf",
184
+
"size": 524288,
185
+
"mimetype": "application/pdf"
186
+
}
187
+
]
188
+
},
189
+
"attachments": {
190
+
"hasFiles": true,
191
+
"fileCount": 1,
192
+
"totalSize": 524288,
193
+
"types": ["application/pdf"],
194
+
"names": ["document.pdf"]
144
195
},
145
196
"timestamp": 1733097600000
146
197
}
147
198
```
148
199
200
+
**New Enhancement**: Events with file attachments now include an `attachments` metadata object providing:
201
+
-`hasFiles`: Boolean indicating presence of files
202
+
-`fileCount`: Total number of attached files
203
+
-`totalSize`: Combined size of all files in bytes
204
+
-`types`: Array of unique MIME types (deduplicated)
205
+
-`names`: Array of all file names (maintains order)
206
+
149
207
## π» Development
150
208
151
209
### Build Commands
@@ -164,11 +222,21 @@ yarn start # Run production build
- Events may be classified as "unknown" for edge cases
211
281
282
+
**File Attachment Correlation Issues:**
283
+
284
+
- Verify `TARGET_PLATFORM` is set correctly in your `.env` file
285
+
- Check correlation logs for timing and buffering details
286
+
- File events without correlation data will fall back to "unknown" source
287
+
- Correlation window is 15 seconds - events outside this window may not correlate
288
+
289
+
**Common Solutions:**
290
+
291
+
- Restart the server if platform detection seems inconsistent
292
+
- Clear Redis cache if experiencing correlation issues: `redis-cli FLUSHDB`
293
+
- Enable debug logging by setting `NODE_ENV=development` for detailed correlation logs
294
+
295
+
## π Integration Benefits
296
+
297
+
### For Bot Developers
298
+
299
+
-**Accurate Source Detection**: No more "unknown" file attachment sources - get precise platform identification
300
+
-**Rich File Metadata**: Access file counts, sizes, types, and names without parsing complex file arrays
301
+
-**Simplified Integration**: Use the `attachments` metadata for quick file handling logic
302
+
-**Backwards Compatibility**: Existing code continues to work unchanged
303
+
304
+
### For Production Systems
305
+
306
+
-**Reliable Correlation**: Memory-based correlation system with 15-second timing windows and automatic fallbacks
307
+
-**Robust Error Handling**: Comprehensive timeout management and duplicate prevention
308
+
-**Scalable Architecture**: Efficient Redis-based queuing with TTL cleanup and deduplication
309
+
-**Production-Ready**: Extensive logging, monitoring, and error recovery mechanisms
310
+
212
311
## π― Contributing
213
312
214
313
Contributions are welcome, create a pull request to this repo and I will review your code. Please consider to submit your pull request to the `dev` branch. Thank you!
215
314
216
315
When contributing, please ensure your code follows the existing TypeScript patterns and includes appropriate error handling.
Copy file name to clipboardExpand all lines: package.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "unthread-webhook-server",
3
-
"version": "1.0.0-beta.5.2",
3
+
"version": "1.0.0-beta.6",
4
4
"description": "A reliable, production-ready Node.js server for processing Unthread.io webhooks with signature verification and smart platform handling.",
0 commit comments