Fix(webhooks): fixed all webhook structures#935
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Greptile Summary
This PR comprehensively fixes webhook functionality across the SimStudio AI platform by addressing variable resolution issues and standardizing webhook structures. The changes span multiple areas:
Webhook Structure Standardization: The PR restructures webhook output schemas for Telegram and Slack triggers to use nested objects (e.g., telegram.message.text instead of flat text), creating consistency across providers. Webhook utilities are updated to provide both top-level and nested properties for backward compatibility.
Discord Webhook Removal: All Discord webhook functionality has been completely removed, including the trigger configuration, provider components, and related infrastructure. This appears to be a strategic decision to eliminate a problematic provider rather than fix it.
Provider Enhancements: Several webhook providers receive significant improvements:
- Airtable webhooks now require OAuth credentials and have proper workflow execution logic
- Microsoft Teams and WhatsApp blocks gain trigger configuration capabilities
- Slack and Telegram get improved setup instructions
- Outlook folder loading support is added to the trigger modal
Variable Resolution Fixes: The trigger handler is enhanced with sophisticated data flattening logic that extracts provider-specific data from nested structures and makes it available at the root level for easier variable access in workflows. This addresses the core issue where webhook payload variables weren't resolving correctly.
Validation Improvements: The serializer now skips validation for trigger blocks since they receive data from external sources rather than user input. Error handling is improved throughout, particularly for Airtable webhook creation failures.
These changes integrate with the existing workflow execution system by maintaining the established patterns for sub-blocks and trigger configurations while fixing the underlying data flow issues that were preventing webhook triggers from functioning properly.
Confidence score: 1/5
- This PR has critical issues that will cause immediate breakage and requires careful review before merging
- Score reflects the complete removal of Discord functionality without proper cleanup and complex webhook restructuring that introduces breaking changes
- Pay close attention to webhook-modal.tsx, discord.tsx (deleted), and trigger-handler.ts for potential runtime errors and data conflicts
22 files reviewed, 3 comments
| // // // Top-level properties for backward compatibility with <blockName.event> syntax | ||
| event: eventObj, |
There was a problem hiding this comment.
syntax: Inconsistent comment formatting: triple slash comment should be double slash
| // // // Top-level properties for backward compatibility with <blockName.event> syntax | |
| event: eventObj, | |
| // Top-level properties for backward compatibility with <blockName.event> syntax | |
| event: eventObj, |
| update_id: { | ||
| type: 'number', | ||
| description: 'Unique identifier for the update', |
There was a problem hiding this comment.
logic: The update_id field is now nested under message, but in the actual Telegram API, update_id is at the root level of the webhook payload, not within the message object. This may cause confusion.
| // Pattern 1: Provider-specific nested object (telegram, microsoftteams, etc.) | ||
| if (provider && starterOutput[provider]) { | ||
| // Copy all properties from provider object to root level for direct access | ||
| const providerData = starterOutput[provider] | ||
| for (const [key, value] of Object.entries(providerData)) { | ||
| if (typeof value === 'object' && value !== null) { | ||
| // Don't overwrite existing top-level properties | ||
| if (!result[key]) { | ||
| result[key] = value | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Keep nested structure for backwards compatibility | ||
| result[provider] = providerData | ||
| } | ||
|
|
||
| // Pattern 2: Provider data directly in webhook.data (based on actual structure) | ||
| else if (provider && webhookData[provider]) { | ||
| const providerData = webhookData[provider] | ||
|
|
||
| // Extract all provider properties to root level | ||
| for (const [key, value] of Object.entries(providerData)) { | ||
| if (typeof value === 'object' && value !== null) { | ||
| // Don't overwrite existing top-level properties | ||
| if (!result[key]) { | ||
| result[key] = value | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Keep nested structure for backwards compatibility | ||
| result[provider] = providerData | ||
| } |
There was a problem hiding this comment.
style: Two similar patterns for provider data extraction that differ only in data source location. Consider extracting this into a shared function to reduce duplication.
Context Used: Context - If a switch statement is large and handles multiple cases, extract each case into separate functions for better maintainability. (link)
* fix for variable format + trig * fixed slack variable * microsoft teams working * fixed outlook, plus added other minor documentation changes and fixed subblock * removed discord webhook logic * added airtable logic * bun run lint * test * test again * test again 2 * test again 3 * test again 4 * test again 4 * test again 4 * bun run lint * test 5 * test 6 * test 7 * test 7 * test 7 * test 7 * test 7 * test 7 * test 8 * test 9 * test 9 * test 9 * test 10 * test 10 * bun run lint, plus github fixed * removed some debug statements simstudioai#935 * testing resolver removing * testing trig --------- Co-authored-by: Adam Gough <adamgough@Adams-MacBook-Pro.local> Co-authored-by: Adam Gough <adamgough@Mac.attlocal.net>
Summary
Fixes the variable resolution and webhook triggers. Some webhooks weren't working, so I fixed functionality as well.
Type of Change
Testing
Tested all webhook triggers (except whatsapp) and fixed the payload variable resolution in all of them.
Checklist
Screenshots/Videos