Database Schema Fixes:
- Added enqueued_at column migration to twp_queued_calls table
- Updated personal queue query to use COALESCE for column compatibility
- Enhanced requeue function to handle both enqueued_at and joined_at columns
- Added dynamic column detection for backwards compatibility
SQL Error Resolution:
- Fixes "Unknown column 'qc.enqueued_at' in 'ORDER BY'" errors
- Maintains compatibility with existing installations
- Ensures proper queue ordering functionality
The code now gracefully handles both old (joined_at) and new (enqueued_at)
column structures, with automatic migration adding the missing column.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Recording Proxy Improvements:
- Enhanced error handling to prevent JSON responses instead of audio
- Added comprehensive logging for Twilio API calls
- Added fallback URL construction from recording SID if URL missing
- Improved error responses with proper HTTP headers
Outbound Call Phone Number Detection:
- Enhanced logic to find customer numbers in complex call structures
- Added search through related calls to find customer phone numbers
- Comprehensive logging for debugging outbound call number assignment
- Handles cases where 'to' field might be empty or contain client identifiers
These changes should resolve:
1. Recording playback returning JSON instead of audio files
2. Missing customer phone numbers in outbound call recordings
3. Better error reporting and debugging capabilities
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Recording Playback Fixes:
- Added proxy_recording_audio endpoint to handle authenticated playback
- Recordings now play through WordPress proxy like voicemails
- Updated Play/Download buttons to use proxy URLs instead of direct Twilio URLs
- No more Twilio login prompts when playing recordings
Phone Number Display Fixes:
- Fixed outbound call recording display to show customer numbers properly
- For browser phone outbound calls, customer number now shows in "From" field
- Added logic to detect client: calls and swap number display appropriately
- Enhanced logging for debugging outbound call number handling
The recording system now works consistently with the voicemail system,
providing seamless authenticated playback without exposing Twilio credentials.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Increased from_number and to_number fields from varchar(20) to varchar(50)
- Added automatic migration to update existing table schemas
- Addresses issue with outbound calls having long phone number formats
- Added force_table_updates() method for manual schema updates
- Enhanced ensure_tables_exist() to always run column migrations
- Fixes recording database insertion failures for international numbers
The original varchar(20) was too small for modern phone number formats,
especially for outbound calls which may include client: prefixes and
international numbers with country codes.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Enhanced call leg detection logic for browser phone calls
- Added comprehensive logging for debugging hold/resume operations
- Fixed hold to properly identify customer vs agent call legs
- Added fallback mechanisms when call relationships are unclear
- Improved resume logic to match hold behavior
- Prevents customer disconnections when agent puts call on hold
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
## New Settings
- Added "Default Queue Music URL" setting in admin settings
- This setting provides fallback music for both queue waits and call hold
- Hold Music URL field can now be left empty to use default queue music
- Better organization of music settings with clear descriptions
## Hold Music Improvements
- Hold music now falls back to default queue music if no specific hold music is set
- Maintains backwards compatibility with existing hold music URLs
- Provides consistent music experience across hold and queue functions
## Queue Music Enhancements
- Queue wait music now uses default queue music as fallback
- No more silent pauses when no queue-specific music is configured
- Improved user experience with continuous music during waits
## Settings Organization
- Default Queue Music is shown first as the primary setting
- Hold Music field has placeholder text indicating it's optional
- Clear descriptions explain the fallback behavior
- Both settings properly registered in WordPress settings API
This creates a more cohesive audio experience where:
1. Admin sets default queue music for system-wide use
2. Individual queues can override with their own music
3. Hold music can be customized or fall back to default
4. No more silent pauses during queue waits
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
## New Call Control Features
- Call hold/unhold with music playback
- Call transfer with agent selection dialog
- Call requeue to different queues
- Call recording with start/stop controls
- Real-time recording status tracking
## Enhanced Transfer System
- Transfer to agents with cell phones (direct)
- Transfer to web phone agents via personal queues
- Automatic queue creation for each user
- Real-time agent availability status
- Visual agent selection with status indicators (📱 phone, 💻 web)
## Call Recordings Management
- New database table for call recordings
- Recordings tab in voicemail interface
- Play/download recordings functionality
- Admin-only delete capability
- Integration with Twilio recording webhooks
## Agent Queue System
- Personal queues (agent_[user_id]) for web phone transfers
- Automatic polling for incoming transfers
- Transfer notifications with browser alerts
- Agent status tracking (available/busy/offline)
## Technical Enhancements
- 8 new AJAX endpoints for call controls
- Recording status webhooks
- Enhanced transfer dialogs with agent selection
- Improved error handling and user feedback
- Mobile-responsive call control interface
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Background Notification Features:
- Implement Web Push Notifications for alerts when browser is minimized
- Add Service Worker for persistent background notification support
- Integrate Page Visibility API to detect when page is in background
- Add browser notification permission request with user consent flow
- Create more aggressive background polling (10 seconds) when page hidden
- Add vibration patterns for mobile device alerts
Bug Fixes:
- Fix Discord/Slack notification parameter order bug preventing delivery
- Add comprehensive logging for notification debugging
- Correct webhook function signatures for proper data passing
Mobile Enhancements:
- Support system notifications on Android browsers
- Add click-to-focus functionality for notifications
- Implement background alert system for multitasking
- Add notification button with visual feedback
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fix 403 Forbidden error in voicemail AJAX by correcting nonce validation
- Create accordion-style collapsible voicemail section with persistent state
- Restructure queue controls to show alert toggle button consistently
- Add global queue actions always visible when user has assigned queues
- Implement smooth slide animations and localStorage state management
- Update dark mode support for new UI elements and improved accessibility
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add AJAX endpoint for fetching user voicemails with stats and recent list
- Create voicemail display section with counts, transcriptions, and playback
- Implement click-to-play functionality for voicemail audio
- Add refresh and view-all buttons with admin page integration
- Style voicemail section with consistent design and dark mode support
- Include visual indicators for recordings and formatted durations
- Add mobile responsive design and hover effects
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fix SMS notifications to use Default SMS From Number instead of destination
- Add Discord webhook notifications for urgent keyword voicemails
- Add Slack webhook notifications for urgent keyword voicemails
- Make notification methods public to allow external calls
- Add urgent_voicemail type support with custom formatting
- Include transcription, keyword, and admin link in notifications
- Use bright red color for urgent alerts in both Discord and Slack
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Update Twilio SDK URL from sdk.twilio.com to unpkg CDN (same as backend)
- Change SDK version from 2.11.1 to 2.11.0 for consistency
- Fix dial number input overflow by adding box-sizing: border-box
- Ensure all elements use border-box sizing model
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
SDK Loading Improvements:
- Increased timeout from 5 to 15 seconds for slower connections
- Added progressive status messages during SDK loading
- Enhanced console logging for debugging
- Added fallback SDK loading mechanism with inline script
- Better error diagnostics showing Twilio object status
Text Contrast Fixes:
- Updated all #333 colors to #212529 for better readability
- Fixed browser phone title, dial buttons, timer, queue headings
- Enhanced dark mode support for all text elements
- Improved readability on both light and dark backgrounds
Technical Changes:
- waitForTwilioSDK() now waits 150 attempts (15 seconds)
- Progressive status updates at 3s, 6s, 10s intervals
- Backup SDK loading via document.createElement
- Comprehensive dark mode color coverage
- Better error messaging for network issues
Accessibility Improvements:
- Higher contrast ratios for WCAG compliance
- Consistent text color hierarchy
- Better visibility in all lighting conditions
- Enhanced mobile readability
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Features Added:
- Queue display showing all assigned queues for the current user
- Real-time queue statistics (waiting calls, capacity)
- Visual indicators for queues with waiting calls (green border, pulse animation)
- Queue selection with click interaction
- Accept next call from selected queue functionality
- Auto-refresh of queue data every 30 seconds
- Mobile-responsive queue interface
Backend Changes:
- New ajax_get_agent_queues() handler to fetch user's assigned queues
- Enhanced ajax_get_waiting_calls() to return structured data
- Proper permission checking for twp_access_agent_queue capability
Frontend Enhancements:
- Interactive queue list with selection states
- Queue controls panel showing selected queue info
- Refresh button for manual queue updates
- Visual feedback for queues with active calls
- Mobile-optimized layout for smaller screens
UI/UX Improvements:
- Queues with waiting calls highlighted with green accent
- Pulsing indicator for active queues
- Auto-selection of first queue with calls
- Responsive design for mobile devices
- Dark mode support for queue elements
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Created TWP_Shortcodes class with [twp_browser_phone] shortcode
- Mobile-first responsive CSS design with touch-friendly interface
- Frontend JavaScript integration with Twilio Voice SDK v2
- Permission checks for logged-in users with twp_access_browser_phone capability
- Haptic feedback and dark mode support
- Configurable shortcode parameters (title, show_title, compact)
- Updated plugin version to 2.1.0 in main file
- Added comprehensive documentation to README.md
Features:
- Visual dialpad with DTMF support
- Real-time connection status indicators
- Call timer and queue management
- Auto-scaling for mobile devices (320px+)
- Optimized for both desktop and mobile use
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Settings & Configuration:
- Added Discord webhook URL, Slack webhook URL settings in admin
- Added notification type toggles (incoming calls, queue timeouts, missed calls)
- Added queue timeout threshold setting (30-1800 seconds)
- Registered all new settings with WordPress options system
Notification System:
- Created TWP_Notifications class for Discord/Slack webhook handling
- Rich message formatting with embeds/attachments for both platforms
- Color-coded notifications (blue=incoming, yellow=timeout, red=missed)
- Comprehensive error handling and logging
Integration Points:
- Incoming calls: Notifications sent when calls enter queues
- Queue timeouts: Automated monitoring via cron job (every minute)
- Missed calls: Notifications for browser phone and general missed calls
- Added notified_timeout column to prevent duplicate timeout notifications
Features:
- Professional Discord embeds with fields and timestamps
- Slack attachments with proper formatting and colors
- Automatic cron job setup for queue timeout monitoring
- Fallback to SMS notifications while Discord/Slack also work
- Configurable notification types and timeout thresholds
This provides real-time call notifications to Discord channels and Slack channels,
helping teams stay informed about incoming calls and queue issues even when
SMS notifications aren't working due to validation delays.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Database Changes:
- Added twp_workflow_phones junction table for many-to-many relationship
- Updated activator to create and manage new table
- Maintained backward compatibility with existing phone_number field
Workflow Management:
- Added set_workflow_phone_numbers() and get_workflow_phone_numbers() methods
- Updated get_workflow_by_phone_number() to check both old and new structures
- Enhanced save/update handlers to support phone_numbers array
- Added AJAX endpoint for retrieving workflow phone numbers
User Interface:
- Replaced single phone number select with dynamic multi-select interface
- Added "Add Number" and "Remove" buttons for managing multiple numbers
- Updated workflow listing to display all assigned phone numbers
- Enhanced JavaScript for phone number management and validation
The webhook routing already supports multiple numbers since get_workflow_by_phone_number()
was updated to check both structures. This feature allows users to assign multiple
Twilio phone numbers to trigger the same workflow.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Standardized client name generation across all files to use alphanumeric only
- Fixed mismatch between token generation and call routing that caused calls to disconnect
- Updated TWP_Workflow, TWP_Webhooks, and TWP_Agent_Manager to use same format
- Client names now consistently formatted as 'agent123Username' without underscores
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Removed underscores and hyphens from client name generation
- Using preg_replace to strip all non-alphanumeric characters
- Twilio requires client names to contain only alphanumeric characters
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed error message display when browser phone initialization fails (now shows actual error instead of "undefined")
- Fixed ajax_get_phone_numbers to use wp_send_json_error instead of wp_die for proper error handling
- Added error handling for phone numbers loading in browser phone interface
- Updated phone_agent role to ensure all necessary capabilities are added to existing roles
- Added automatic capability updates for existing phone_agent roles on plugin load
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed phone agents getting 'Unauthorized' error when accessing voicemails by checking for twp_access_voicemails capability
- Fixed missing ElevenLabs parameter in queue TwiML generation that prevented announcement messages
- Fixed IVR voicemail messages not being saved correctly - now properly assigns message field based on action type
- Added proper permission checks for both ajax_get_voicemail and ajax_get_voicemail_audio functions
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Changed create_voicemail_twiml() from private to public method to fix fatal error when accessing voicemail from IVR
- Added auto-loading of ElevenLabs voices when switching to TTS option for new workflow steps
- Voices now load automatically when user selects "Use Text-to-Speech" radio button
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>