Remove Slack Integration and Replace with Email Notifications #1083
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove Slack Integration and Replace with Email Notifications
Closes #1075
Overview
This PR completely removes the Slack integration from the Helper codebase and replaces all Slack notifications with email notifications. All functionality is preserved, ensuring zero functionality loss while eliminating Slack dependencies.
Changes Summary
Phase 1: Replace Slack Notifications with Email Notifications
Overview
This PR implements Phase 1 of migrating from Slack notifications to email notifications. All four notification types (Daily Reports, Weekly Reports, VIP Notifications, and Response Time Alerts) now send emails via Resend instead of posting to Slack channels. The implementation includes a robust email infrastructure with user preference management, modern responsive email templates, and comprehensive test coverage.
Core Logic Implementation
1. Email Notification Service (
lib/email/notifications.ts)The core email sending service provides four main functions:
sendDailyReportEmail()- Sends daily mailbox summaries with key metricssendWeeklyReportEmail()- Sends weekly team performance reportssendVipNotificationEmail()- Sends VIP customer message notificationssendResponseTimeAlertEmail()- Sends alerts for overdue ticketsKey Features:
@react-email/render2. Team Member Email Management (
lib/email/teamMembers.ts)getTeamMemberEmails(notificationType?)- Retrieves team member emails with preference filteringgetTeamMembersWithPreferences()- Returns team members with their full preference data3. User Preferences System
Database Schema Changes (
db/schema/userProfiles.ts):preferencesJSONB field to includeemailNotificationsobject:undefined= opt-in (users receive emails unless explicitly set tofalse)4. Job Updates
All existing background jobs have been updated to use email notifications:
jobs/generateDailyReports.tssendDailyReportEmail()jobs/generateWeeklyReports.tssendWeeklyReportEmail()jobs/notifyVipMessage.tssendVipNotificationEmail()jobs/checkAssignedTicketResponseTimes.tssendResponseTimeAlertEmail()jobs/checkVipResponseTimes.tssendResponseTimeAlertEmail()lib/email/vipNotifications.tsupdateVipMessageOnClose()for closed conversation notificationsEmail Templates & UI Consistency
All email templates are built using React Email components and styled to match the application's design system. The templates are located in
lib/emails/:Design System Consistency
hsl(0, 67%, 17%)) fromglobals.css-apple-system, BlinkMacSystemFont, 'Segoe UI', ...)Responsive Design
All templates are fully responsive and mobile-friendly:
maxWidth: "100%"for mobile compatibilityTemplate Files
lib/emails/dailyReport.tsxlib/emails/weeklyReport.tsxlib/emails/vipNotification.tsxlib/emails/responseTimeAlert.tsxCommon Template Features
Testing
Unit Tests
tests/lib/email/notifications.test.ts(408 lines)tests/lib/email/teamMembers.test.ts(213 lines)getTeamMemberEmails()with various scenarios:getTeamMembersWithPreferences()functionTest Coverage
Changed Files
Core Implementation
lib/email/notifications.ts- Main email notification service (307 lines)lib/email/teamMembers.ts- Team member email retrieval with preferences (63 lines)lib/email/vipNotifications.ts- VIP notification helper (65 lines)Email Templates
lib/emails/dailyReport.tsx- Daily report email template (369 lines)lib/emails/weeklyReport.tsx- Weekly report email template (347 lines)lib/emails/vipNotification.tsx- VIP notification email template (436 lines)lib/emails/responseTimeAlert.tsx- Response time alert email template (344 lines)Job Updates
jobs/generateDailyReports.ts- Updated to use email notificationsjobs/generateWeeklyReports.ts- Updated to use email notificationsjobs/notifyVipMessage.ts- Updated to use email notificationsjobs/checkAssignedTicketResponseTimes.ts- Updated to use email notificationsjobs/checkVipResponseTimes.ts- Updated to use email notificationsDatabase Schema
db/schema/userProfiles.ts- AddedemailNotificationspreferences to JSONB fieldTests
tests/lib/email/notifications.test.ts- Comprehensive unit tests for email functions (408 lines)tests/lib/email/teamMembers.test.ts- Unit tests for team member email functions (213 lines)Technical Details
Dependencies
Environment Variables Required
RESEND_API_KEY- Resend API key for email sendingRESEND_FROM_ADDRESS- Sender email addressError Handling
Performance
Promise.all()Migration Notes
Phase 2: Remove Slack Integration
Overview
This PR completes the removal of all Slack integration code from the codebase. All Slack functionality has been successfully replaced with email notifications (implemented in Phase 1), ensuring zero functionality loss while eliminating Slack dependencies.
Files Removed
Core Slack Integration Files
lib/slack/(entire directory)lib/slack/client.ts- Slack API client utilitieslib/slack/constants.ts- Slack-related constantslib/slack/linkUnfurl.ts- Slack link unfurling functionalitylib/slack/shared.ts- Shared Slack utilitieslib/slack/vipNotifications.ts- VIP notification helperslib/slack/agent/- Slack agent message handlingAPI Routes
app/api/webhooks/slack/event/route.ts- Slack event webhook handlerapp/api/webhooks/slack/response/route.ts- Slack response webhook handlerapp/api/connect/slack/callback/route.ts- Slack OAuth callback handlerBackground Jobs
jobs/handleSlackAgentMessage.ts- Slack agent message processing jobtRPC Routers
trpc/router/mailbox/slack.ts- Slack-related API endpointsUI Components
app/(dashboard)/settings/integrations/slackSetting.tsx- Slack settings UI componentcomponents/useShowToastForSlackConnectStatus.ts- Slack connection status toast hookapp/(dashboard)/icons/slack.svg- Slack icon SVGMarketing Assets
packages/marketing/public/slack-logo-icon.png- Slack logo imagepackages/marketing/app/slackNotification.tsx- Marketing demo component (Slack notification UI)packages/marketing/app/slackInterface.tsx- Marketing demo component (Slack interface UI)Database Schema Changes
Migration File
db/drizzle/0124_remove_slack_integration.sql- Comprehensive migration removing all Slack-related columns and indexesSchema Files Updated
db/schema/mailboxes.ts- Removed fields:slackAlertChannelslackBotTokenslackBotUserIdslackTeamIdvipChannelIddb/schema/conversationMessages.ts- Removed fields:slackChannelslackMessageTsmessages_slack_message_ts_idxdb/schema/notes.ts- Removed fields:slackMessageTsslackChanneldb/schema/faqs.ts- Removed fields:slackChannelslackMessageTsdb/schema/agentThreads.ts- Removed fields:slackChannelagent_threads_slack_channel_thread_ts_idxdb/schema/agentMessages.ts- Removed fields:slackChannelagent_messages_slack_unique_idxDatabase Columns Dropped
mailboxes_mailbox:slack_escalation_channel,slack_bot_token,slack_bot_user_id,slack_team_id,vip_channel_idconversations_email:slack_channel,slack_message_tsconversations_note:slack_message_ts,slack_channelfaqs:slack_channel,slack_message_tsagent_threads:slack_channelagent_messages:slack_channelIndexes Dropped
messages_slack_message_ts_idxagent_threads_slack_channel_thread_ts_idxagent_messages_slack_unique_idxCode Updates
Data Access Layer
lib/data/mailbox.ts:getSlackConnectUrl(),disconnectSlack(),slackConnected,slackConnectUrl,slackAlertChannelfromgetMailboxInfo()lib/data/conversationMessage.ts:slackChannelandslackMessageTsfromserializeMessage()andcreateReply()lib/data/note.ts:slackChannelandslackMessageTsfromaddNote()lib/data/knowledge.ts:approveSuggestedEdit()andrejectSuggestedEdit()handleKnowledgeBankSlackAction()andopenTweakSuggestedEditModal()lib/data/user.ts:findUserViaSlack()lib/data/conversation/search.ts:Background Jobs
jobs/index.ts:handleSlackAgentMessagefromeventJobsjobs/trigger.ts:"slack/agent.message"event definitionjobs/suggestKnowledgeBankChanges.ts:notifySuggestedEdit()jobs/generateWeeklyReports.ts: Already migrated to email (Phase 1)jobs/generateDailyReports.ts: Already migrated to email (Phase 1)jobs/checkAssignedTicketResponseTimes.ts: Already migrated to email (Phase 1)API Routes (tRPC)
trpc/router/mailbox/index.ts:slackRouterimport and registrationslackAlertChannelandvipChannelIdfromupdateinput schemaUI Components
app/(dashboard)/settings/[tab]/page.tsx:SlackSettingcomponent from Integrations tabapp/(dashboard)/settings/customers/customerSetting.tsx:vipChannelIdfrom update mutationapp/(dashboard)/[category]/conversation/messageItem.tsx:Environment Variables
lib/env.ts:SLACK_CLIENT_IDSLACK_CLIENT_SECRETSLACK_SIGNING_SECRETTest Files Updated
Unit Tests
tests/lib/data/mailbox.test.ts:disconnectSlack()testsgetMailboxInfo()assertionstests/lib/data/conversationMessage.test.ts:createReply()testtests/lib/data/note.test.ts:slackChannelandslackMessageTsfrom test assertionsJob Tests
tests/jobs/generateWeeklyReports.test.ts:sendWeeklyReportEmail()callstests/jobs/generateDailyReports.test.ts:sendDailyReportEmail()callstests/jobs/checkAssignedTicketResponseTimes.test.ts:sendResponseTimeAlertEmail()callsIntegration Tests
tests/trpc/router/mailbox.test.ts:tests/trpc/router/mailbox/conversations/index.test.ts:tests/evals/support/chat.ts:vipChannelIdfieldE2E Tests
tests/e2e/customer-settings/customerSettings.spec.ts:Documentation Updates
packages/marketing/content/docs/integrations.mdx:packages/marketing/content/docs/development/overview.md:libdirectory descriptionFunctionality Preservation
All Slack functionality has been successfully replaced with email notifications:
sendWeeklyReportEmail()replaces Slack channel postssendDailyReportEmail()replaces Slack channel postssendResponseTimeAlertEmail()replaces Slack alertsAll notification features continue to work seamlessly through the email notification system implemented in Phase 1.
Migration Instructions
Run the database migration:
This will execute
db/drizzle/0124_remove_slack_integration.sqlto remove all Slack-related columns and indexes.Remove environment variables (if present):
SLACK_CLIENT_IDSLACK_CLIENT_SECRETSLACK_SIGNING_SECRETNo code changes required: All functionality automatically uses email notifications.
Verification Checklist
✅ No Slack references remain in schema files
✅ No Slack references remain in
lib/files (excluding marketing demo components)✅ All test files updated and passing
✅ Migration file includes all necessary column drops
✅ Environment variables removed from schema
✅ Documentation updated
✅ All functionality preserved via email notifications
Breaking Changes
✅ Phase 3: Testing
Untitled.video.-.Made.with.Clipchamp.2.mp4
Functionality Mapping
Testing
Breaking Changes
Migration Notes
Run the database migration before deploying:
Remove Slack environment variables from production environment
Ensure email configuration is set up:
RESEND_API_KEYmust be configuredRESEND_FROM_ADDRESSmust be configuredNo code changes required - All functionality automatically uses email notifications
Notify users about the change from Slack to email notifications
Verification
AI Disclosure
🤖 This PR was developed with assistance from Claude (Anthropic) for: