Add Slack webhook integration to demo form#1484
Conversation
- Add SLACK_DEMO_WEBHOOK_URL constant - Create send_data_to_slack function in postog_metrics.py - Update send_demo_event to call both PostHog and Slack webhooks - Maintain existing PostHog functionality while adding Slack integration Co-Authored-By: tom@reflex.dev <tom@reflex.dev>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
PR Summary
Added Slack webhook integration for demo form submissions, with potential security and data mapping concerns that need addressing.
- Hardcoded Slack webhook URL in
pcweb/constants.pyshould be moved to environment variables for security - Incorrect data mapping in
pcweb/telemetry/postog_metrics.pywhere company_email is mapped to businessName field - Basic error handling in
send_data_to_slack()needs more detailed logging - New reusable DemoEvent object pattern in
pcweb/pages/pricing/header.pyimproves code maintainability
3 files reviewed, 4 comments
Edit PR Review Bot Settings | Greptile
pcweb/telemetry/postog_metrics.py
Outdated
| "lookingToBuild": event_instance.internal_tools, | ||
| "businessName": event_instance.company_email, |
There was a problem hiding this comment.
logic: Field mapping appears incorrect - company_email is being mapped to businessName. This may cause confusion in Slack notifications.
| "lookingToBuild": event_instance.internal_tools, | |
| "businessName": event_instance.company_email, | |
| "lookingToBuild": event_instance.internal_tools, | |
| "businessName": event_instance.company_name, |
pcweb/telemetry/postog_metrics.py
Outdated
| except Exception: | ||
| log("Error sending data to Slack webhook") |
There was a problem hiding this comment.
style: Consider logging the actual error details to help with debugging webhook failures.
pcweb/pages/pricing/header.py
Outdated
| # Send to Slack (new) | ||
| await send_data_to_slack(demo_event) |
There was a problem hiding this comment.
style: consider adding error handling around the Slack call since webhook failures shouldn't block the form submission
| # Send to Slack (new) | |
| await send_data_to_slack(demo_event) | |
| # Send to Slack (new) | |
| try: | |
| await send_data_to_slack(demo_event) | |
| except Exception as e: | |
| # Log error but don't block form submission | |
| print(f"Failed to send to Slack: {e}") |
pcweb/constants.py
Outdated
| # Posthog | ||
| POSTHOG_API_KEY = os.getenv("POSTHOG_API_KEY") | ||
|
|
||
| SLACK_DEMO_WEBHOOK_URL: str = "https://hooks.slack.com/triggers/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" |
There was a problem hiding this comment.
logic: Move webhook URL to environment variable like other sensitive URLs in this file (e.g. line 102's POSTHOG_API_KEY)
| SLACK_DEMO_WEBHOOK_URL: str = "https://hooks.slack.com/triggers/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" | |
| SLACK_DEMO_WEBHOOK_URL: str = os.environ.get("SLACK_DEMO_WEBHOOK_URL") |
- Fix field mapping: use company_name for businessName instead of company_email - Improve error logging with detailed error messages - Add error handling around Slack webhook call to prevent blocking form submission - Use environment variable for webhook URL with fallback to hardcoded value - Add missing log import in header.py Co-Authored-By: tom@reflex.dev <tom@reflex.dev>
- Add phone_number field to DemoEvent dataclass with default empty string - Add phone number input field to form UI using text_input_field helper - Update form submission handler to include phone number in DemoEvent - Update Slack webhook payload to include phoneNumber field - Phone number field is optional with tel input type and proper placeholder - Maintains consistent styling with existing form fields Co-Authored-By: tom@reflex.dev <tom@reflex.dev>
…s://git-manager.devin.ai/proxy/github.com/reflex-dev/reflex-web into devin/1752180903-add-slack-webhook-integration
Add Slack webhook integration and optional phone number field to demo form
Summary
This PR adds Slack webhook integration to the existing demo form, allowing form submissions to be sent to both PostHog (existing) and a specified Slack channel simultaneously. Additionally, an optional phone number field has been added to the form.
Key Changes:
send_data_to_slack()function to send form data to Slack webhooksend_demo_event()to call both PostHog and Slack webhooks in parallelDemoEventdataclass to include phone number fieldReview & Testing Checklist for Human
/pricingpage to verify both PostHog and Slack receive the data correctly with all fields including phone numberSLACK_DEMO_WEBHOOK_URLenvironment variable is properly configured in production to avoid exposing the hardcoded fallback URLDiagram
%%{ init : { "theme" : "default" }}%% graph TB subgraph "Form Submission Flow" A["pcweb/pages/pricing/header.py<br/>QuoteFormState.submit()"]:::major-edit B["pcweb/pages/pricing/header.py<br/>send_demo_event()"]:::major-edit C["pcweb/telemetry/postog_metrics.py<br/>send_data_to_posthog()"]:::context D["pcweb/telemetry/postog_metrics.py<br/>send_data_to_slack()"]:::major-edit E["pcweb/telemetry/postog_metrics.py<br/>DemoEvent dataclass"]:::major-edit F["pcweb/constants.py<br/>SLACK_DEMO_WEBHOOK_URL"]:::minor-edit end subgraph "External Services" G["PostHog API"]:::context H["Slack Webhook"]:::context end A --> B B --> C B --> D E --> C E --> D F --> D C --> G D --> H subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
/home/ubuntu/screenshots/localhost_3000_215328.pngand/home/ubuntu/screenshots/localhost_3000_215406.pngshowing successful form submission with phone number field