Skip to content

Fix(webhooks): fixed all webhook structures#935

Merged
waleedlatif1 merged 33 commits intostagingfrom
fix/telegram-wh
Aug 11, 2025
Merged

Fix(webhooks): fixed all webhook structures#935
waleedlatif1 merged 33 commits intostagingfrom
fix/telegram-wh

Conversation

@aadamgough
Copy link
Contributor

@aadamgough aadamgough commented Aug 11, 2025

Summary

Fixes the variable resolution and webhook triggers. Some webhooks weren't working, so I fixed functionality as well.

Type of Change

  • Bug fix

Testing

Tested all webhook triggers (except whatsapp) and fixed the payload variable resolution in all of them.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

Screenshot 2025-08-10 at 11 12 09 PM

@vercel
Copy link

vercel bot commented Aug 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2025 7:01pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Aug 11, 2025 7:01pm

@aadamgough aadamgough changed the title Fix/telegram wh Fix(webhooks): fixed all webhook structures Aug 11, 2025
@vercel vercel bot temporarily deployed to Preview – docs August 11, 2025 06:14 Inactive
@aadamgough aadamgough marked this pull request as ready for review August 11, 2025 06:18
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Edit Code Review Bot Settings | Greptile

Comment on lines +466 to +467
// // // Top-level properties for backward compatibility with <blockName.event> syntax
event: eventObj,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Inconsistent comment formatting: triple slash comment should be double slash

Suggested change
// // // Top-level properties for backward compatibility with <blockName.event> syntax
event: eventObj,
// Top-level properties for backward compatibility with <blockName.event> syntax
event: eventObj,

Comment on lines +25 to +27
update_id: {
type: 'number',
description: 'Unique identifier for the update',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 64 to 97
// 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
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@vercel vercel bot temporarily deployed to Preview – docs August 11, 2025 07:30 Inactive
@vercel vercel bot temporarily deployed to Preview – docs August 11, 2025 07:31 Inactive
Adam Gough added 2 commits August 11, 2025 00:33
@vercel vercel bot temporarily deployed to Preview – docs August 11, 2025 08:27 Inactive
@vercel vercel bot temporarily deployed to Preview – docs August 11, 2025 18:57 Inactive
@waleedlatif1 waleedlatif1 merged commit 41cc0cd into staging Aug 11, 2025
5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/telegram-wh branch August 15, 2025 17:04
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants