Commit Graph

54 Commits

Author SHA1 Message Date
051de4e3e1 Implement agent queue transfer functionality for browser phones
- Added ajax_get_transfer_agents endpoint to retrieve available agents
- Enhanced transfer system to support both phone numbers and personal queues
- Updated JavaScript transfer dialog to show agent selection with queue options
- Added personal queue database table creation for agent-to-agent transfers
- Implemented transfer-to-queue functionality using Twilio enqueue
- Added comprehensive CSS styling for new agent transfer dialog
- Each agent gets a personal queue (format: agent_{id}) for browser phone transfers
- Supports both phone transfers and browser phone queue transfers
- Enhanced UI shows transfer method options (phone vs browser phone queue)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 16:26:39 -07:00
3f1d115aa0 Fix critical hold issue preventing call disconnections
- 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>
2025-08-30 16:20:16 -07:00
315a774447 Fix recording database storage and improve error handling
## Database Issues Fixed
- Ensure database table exists before recording operations
- Better error handling when database insert fails
- Added fallback to stop recording in Twilio even if not found in database
- Enhanced error logging for database operations

## Improved Recording Error Handling
- Stop recording attempts Twilio API even if database record missing
- Better error messages distinguish between database vs Twilio issues
- Recording start validates database insert success before proceeding
- Enhanced debugging to identify where recordings are failing

## JavaScript Debugging Enhanced
- Added console logging for all recording operations
- Log recording SID and call SID on start/stop
- Better error messages in browser console
- Detailed AJAX failure logging

## Technical Improvements
- Call TWP_Activator::ensure_tables_exist() before recording operations
- Return call_sid in recording start response for debugging
- Graceful handling of recordings that exist in Twilio but not database
- Better validation of recording SID before stop operations

This should resolve the "recording not found in database" error by:
1. Ensuring the database table exists
2. Providing better error feedback when database operations fail
3. Allowing recordings to be stopped even if database tracking failed
4. Enhanced logging to identify root cause of storage issues

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 16:08:34 -07:00
e216abdd86 Fix hold functionality to put customer on hold instead of agent
## Hold Logic Fix
- Now correctly identifies which call leg to put on hold
- For browser phone calls (client: prefix), looks for parent call to hold customer
- For regular calls, puts the call recipient on hold
- Agent remains connected and can hear when customer speaks

## Smart Call Leg Detection
- Detects browser phone calls by 'client:' prefix in 'To' field
- Uses parentCallSid to find the customer's call leg
- Falls back gracefully if parent call structure isn't available
- Added detailed error logging to help debug call structures

## Improved User Experience
- Customer hears "Please hold while we assist you" before hold music
- Agent stays connected and can monitor the call
- Resume includes "Thank you for holding" message
- Better messaging tailored to who is actually being put on hold

## Technical Details
- Added call structure analysis and logging
- Proper handling of Twilio's call hierarchy
- Different TwiML logic for browser vs regular phone calls
- Maintains backwards compatibility with existing call flows

This resolves the issue where agents were being put on hold instead of customers when using the browser phone interface.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 16:06:54 -07:00
0d0667cf3d Replace obnoxious cowbell with gentle bell tone as default hold music
## Default Music Improvement
- Changed from Twilio's annoying cowbell.mp3 to gentle bell-ringing-05.wav
- Much more pleasant and professional sounding default
- Updated both settings default and code fallback

## Better Music Suggestions
- Added comprehensive list of recommended music sources in admin interface
- Suggested alternatives: WordPress Media Library, Freesound.org, Archive.org, Incompetech.com, Zapsplat.com
- Provided guidance for different business types and use cases

## User Experience
- No more jarring cowbell sounds for new installations
- Clear instructions on how to customize with better alternatives
- Emphasis on using WordPress Media Library for reliability

The new default provides a much more professional audio experience while still maintaining functionality for users who haven't customized their hold music yet.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 15:55:07 -07:00
308e4851ac Add default queue music setting and improve hold music fallback
## 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>
2025-08-30 15:51:48 -07:00
e6e177a114 Improve call recording functionality with better debugging and Call SID detection
## Recording Issues Fixed
- Enhanced Call SID detection for browser phone calls
- Try multiple methods to get Call SID: parameters.CallSid, customParameters.CallSid, outgoingConnectionId, sid
- Added comprehensive console logging for debugging recording issues
- Better error handling and user feedback

## Backend Improvements
- Verify call exists and is in-progress before attempting recording
- Enhanced error logging with call status and details
- Improved AJAX error responses with specific error messages
- Database insert error checking and logging

## Frontend Improvements
- Multiple Call SID detection methods for browser phone compatibility
- Console logging of call object and Call SID for debugging
- Enhanced error handling with xhr response details
- Validation of active call before recording attempt

## Debugging Features
- Detailed error logs in PHP error log
- Console logging in browser for JavaScript debugging
- Specific error messages for different failure scenarios
- Call status validation to ensure recording is possible

These changes should resolve the "recording not working" issue by properly detecting the Call SID for browser phone calls and providing detailed debugging information.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 15:49:31 -07:00
0bbc499878 Fix call hold/resume and recording issues, add configurable hold music
## Hold/Resume Fixes
- Fixed call disconnection issue when resuming from hold
- Changed resume logic from webhook redirect to empty TwiML continuation
- This allows browser phone calls to continue normally after hold

## Recording Stop Improvements
- Enhanced error handling for recording stop functionality
- Check recording status in database before attempting Twilio API call
- Handle cases where recording is already stopped or completed
- Graceful fallback if Twilio API call fails
- Better logging for debugging recording issues

## Configurable Hold Music
- Added "Hold Music URL" setting in admin Settings page
- Allows admins to specify custom hold music instead of default cowbell
- Supports MP3 and WAV files from any publicly accessible URL
- Default remains Twilio's cowbell.mp3 for backwards compatibility
- Setting automatically saved/loaded through WordPress settings API

## Technical Details
- Hold music URL retrieved via get_option() with fallback
- Recording stop checks database state before API calls
- Improved error messages and logging throughout
- All changes maintain backwards compatibility

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 15:46:19 -07:00
060b95c710 Fix browser phone call control buttons not appearing
## Frontend Issues Fixed
- Call control panel visibility during connected calls
- Button event handlers properly bound
- JavaScript localization includes user_id for personal queues

## Backend Browser Phone Enhanced
- Added complete call control panel with Hold, Transfer, Requeue, Record buttons
- Integrated admin-specific JavaScript functions for all call controls
- Added agent selection dialogs with status indicators
- Call control panel shows/hides based on call state
- Button state management (hold/unhold, record/stop recording)
- WordPress admin styling with dashicons

## Technical Improvements
- Separate admin button IDs to avoid conflicts with frontend
- Enhanced call state management in setupCallHandlers()
- Admin notification system for user feedback
- Proper cleanup when calls end

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 15:35:08 -07:00
dc3c12e006 Add comprehensive call control features and web phone transfer capabilities
## 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>
2025-08-30 11:52:50 -07:00
7398f97f24 Fix notification button overflow on tablets and bump version to 2.2.0
- Fix notification button text overflow on tablet devices
- Add tablet-specific media queries for button sizing and layout
- Shorten button text from "Enable Notifications" to "Enable Alerts"
- Add responsive button constraints with min/max width and text overflow handling
- Stack queue action buttons vertically on tablets for better fit
- Bump plugin version from 2.1.0 to 2.2.0 to include all recent enhancements

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-15 17:12:33 -07:00
d050f1538b Add background notifications and fix Discord/Slack notification bugs
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>
2025-08-15 16:51:47 -07:00
9832f899c3 Fix alert system to stop when queues become empty
- Enhance checkForNewCalls to monitor queue emptiness and auto-stop alerts
- Update startAlert to verify waiting calls exist before starting
- Add continuous monitoring to stop alerts when no calls remain
- Prevent false alerts when calls disconnect before pickup
- Add console logging for better alert behavior tracking

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-15 10:28:39 -07:00
872182a393 Fix browser phone issues and improve UI organization
- 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>
2025-08-15 09:56:04 -07:00
f26cb24dfd Add comprehensive voicemail integration to browser phone
- 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>
2025-08-15 09:29:35 -07:00
d63eec129a Enhance browser phone with real-time updates and audible alerts
- Fix token expiration: Extend refresh buffer to 10 minutes for reliability
- Add real-time queue updates: Reduce polling to 5 seconds for instant feedback
- Implement audible alert system: 30-second repeating notifications with user toggle
- Optimize Discord/Slack notifications: Non-blocking requests for immediate delivery
- Add persistent alert preferences: Toggle button with localStorage integration
- Clean up debug file: Remove unused debug-phone-numbers.php

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-15 09:14:51 -07:00
2cb9b9472d Add automatic token refresh for browser phone to prevent timeouts
- Implement proactive token refresh 5 minutes before expiry (1-hour tokens)
- Add call-safe refresh logic that postpones refresh during active calls
- Replace fixed-interval refresh with smart scheduling based on token expiry
- Add proper cleanup on page unload to prevent memory leaks
- Enhance error handling with retry mechanisms for network failures
- Apply to both admin browser phone page and frontend shortcode

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 12:01:05 -07:00
8c78e0cb11 Fix urgent voicemail SMS from number and add Discord/Slack notifications
- 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>
2025-08-13 20:30:58 -07:00
f84914281d Add WordPress timezone support and fix dashboard phone number display
- Add format_timestamp_with_timezone() helper to convert UTC to WP timezone
- Update all timestamp displays to use WordPress timezone setting
- Fix dashboard showing call SID instead of phone numbers in From field
- Fix dashboard showing "System" instead of actual phone numbers in To field
- Query actual from_number and to_number fields for dashboard display

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 17:48:28 -07:00
9ccd78c125 Fix admin queue waiting calls filter error
- Change ajax_get_waiting_calls response format to return array directly
- Fixes JavaScript error "waitingCalls.filter is not a function"
- Ensures compatibility with frontend filter operations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 17:35:14 -07:00
95b54ce2df Fix browser phone Twilio SDK v2 API compatibility issues
- Update makeCall function to use async/await with new SDK
- Wrap connect params in {params: params} object as required by SDK v2
- Make setupTwilioDevice async and await device.register()
- Add proper error handling for Promise-based API calls

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 15:20:14 -07:00
3bdfc3f490 Fix browser phone Twilio SDK loading and CSS layout issues
- 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>
2025-08-13 15:03:08 -07:00
e3fab38d01 Fix SDK timeout and improve text contrast
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>
2025-08-13 14:22:37 -07:00
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
9bef599406 Fix frontend shortcode AJAX nonce validation issues
- Added verify_ajax_nonce() helper method to check both admin and frontend nonces
- Updated ajax_generate_capability_token() to accept frontend nonce
- Updated ajax_get_phone_numbers() to accept frontend nonce
- Updated ajax_get_waiting_calls() to accept frontend nonce
- Updated ajax_accept_next_queue_call() to accept frontend nonce
- Resolves 403 AJAX errors when using shortcode on frontend

The shortcode creates 'twp_frontend_nonce' while admin uses 'twp_ajax_nonce'
Now both are accepted by the AJAX handlers for proper frontend functionality

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 13:50:56 -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
bef2259943 Update README.md with comprehensive documentation and cleanup test files
- Added Discord & Slack notifications section with configuration guide
- Documented multiple phone numbers per workflow feature
- Updated version to 2.1.0 with full changelog
- Enhanced configuration sections for new features
- Added database structure documentation for twp_workflow_phones table
- Removed obsolete test files (test-sdk.php, test-capabilities.php, test-ajax-response.php)
- Updated plugin header with new version and repository URL

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 11:24:29 -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
97a064bf83 Fix validation error for multiple phone numbers
Updated workflow save validation to check for phone_numbers[] array
instead of the old single phone_number field. Now properly validates
that at least one phone number is selected before allowing save.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 10:38:30 -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
b3ca14a151 testing progress 2025-08-12 07:11:13 -07:00
86a57b3285 testing progress 2025-08-12 07:10:12 -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