Commit Graph

25 Commits

Author SHA1 Message Date
24e3a3fcc2 Fix critical browser phone shortcode issues
Issues Fixed:
1. 🎵 Audio Error: Removed missing ringtone.mp3 causing 404 error
2. 📡 Twilio SDK Loading: Added proper SDK availability checking and retry mechanism
3. 🎨 Contrast Issues: Improved readability with darker text colors

Technical Changes:
- Removed hardcoded ringtone.mp3 reference causing 404 errors
- Added waitForTwilioSDK() function with 5-second timeout and retry logic
- Changed Twilio SDK loading to head (false flag) for better availability
- Enhanced error handling with specific Twilio SDK load failure messages
- Improved text contrast: #6c757d → #495057, #495057#212529
- Enhanced dark mode colors for better accessibility

UI Improvements:
- Status text: font-weight 600, color #212529 for better visibility
- Labels and selects: improved contrast ratios
- Queue info: better text color for mobile readability
- Call status: font-weight 600 for prominence
- Dark mode: complete color scheme overhaul with proper contrast

Error Handling:
- Graceful SDK loading with visual feedback
- Clear error messages for troubleshooting
- Automatic retry mechanism for network issues
- Timeout handling for slow connections

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 14:09:36 -07:00
12c285dc90 Add comprehensive queue management to browser phone shortcode
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>
2025-08-13 13:58:24 -07:00
4c353096fe Add mobile-friendly browser phone shortcode for frontend use
- 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>
2025-08-13 13:45:25 -07:00
534d343526 Implement Discord and Slack notifications for call events
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>
2025-08-13 10:47:59 -07:00
aa58b45501 Implement multiple phone numbers per workflow feature
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>
2025-08-13 10:35:21 -07:00
30b0cd355f Fix browser phone client name mismatch causing immediate disconnection
- 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>
2025-08-13 10:21:57 -07:00
c0f0ea8158 Fix browser phone client name to be alphanumeric only
- 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>
2025-08-13 10:15:39 -07:00
140a585085 Fix browser phone permission issues for phone agents
- 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>
2025-08-13 10:14:20 -07:00
7beb0aa4f3 Fix voicemail and queue announcement issues
- 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>
2025-08-13 10:04:20 -07:00
7a539df27a Fix voicemail access and ElevenLabs voice loading issues
- 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>
2025-08-13 09:47:10 -07:00
a5f6ab8b64 testing progress 2025-08-12 14:46:30 -07:00
f6429110e5 testing progress 2025-08-12 10:36:32 -07:00
1633eb46df testing progress 2025-08-12 10:04:31 -07:00
2d6767033b testing progress 2025-08-12 09:54:32 -07:00
e18e046431 testing progress 2025-08-12 09:12:54 -07:00
75fae0fbdb testing progress 2025-08-12 07:26:19 -07:00
003015a4b1 testing progress 2025-08-12 07:22:45 -07:00
39eb3b96b5 testing progress 2025-08-12 07:21:20 -07:00
2d8420c7a2 testing progress 2025-08-12 07:18:25 -07:00
51dd3077d2 testing progress 2025-08-12 07:05:47 -07:00
304b5de40b progress made 2025-08-11 20:31:48 -07:00
805af2f199 Fix Number display 2025-08-07 16:46:51 -07:00
3b499e2074 code push 2025-08-07 15:24:29 -07:00
b5e091d845 twilio project revision 2025-08-06 16:04:03 -07:00
c6edbbeba7 code revision 2025-08-06 15:25:47 -07:00