Fix hold/resume functionality and customer number detection

CRITICAL FIXES:
- Fixed hold/resume functions to use proper Hold Queue system instead of empty TwiML
- Enhanced customer number detection for voicemail and call recording interfaces
- Resolved customer disconnections during hold/resume operations on outbound calls

Hold/Resume System Improvements:
- Updated ajax_toggle_hold() to use TWP_User_Queue_Manager for proper queue management
- Fixed resume function to redirect calls back to appropriate queues (personal/shared)
- Added comprehensive logging for hold queue operations and call leg detection
- Enhanced hold experience with proper TTS messages and queue tracking

Customer Number Detection Enhancements:
- Enhanced handle_voicemail_callback() with fallback logic for missing From parameters
- Added browser phone detection to identify client: calls and find real customer numbers
- Enhanced call recording to use find_customer_call_leg() for proper customer identification
- Fixed admin interfaces to show actual phone numbers instead of "client:agentname"

Technical Improvements:
- Integrated Hold Queue system with existing call leg detection infrastructure
- Added proper TwiML generation for hold/resume operations
- Enhanced error handling and logging for debugging complex call topologies
- Maintains database consistency with queue position tracking

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-01 09:34:07 -07:00
parent 5b6011bdb8
commit ae92ea2c81
5 changed files with 1734 additions and 682 deletions

View File

@@ -109,6 +109,20 @@ This plugin **requires** the Twilio PHP SDK v8.7.0 to function. The plugin will
## Recent Updates
### CRITICAL: Outbound Call Issues Fixed (September 2025)
- **Customer Disconnection Issue Resolved**: Fixed major problem where hold, transfer, and requeue functions were disconnecting customers in outbound calls
- **Call Leg Detection System**: New intelligent system identifies customer vs agent call legs in complex call topologies
- **Browser Phone Transfers**: Fixed "Invalid phone number format" errors when transferring to browser phone agents
- **Outbound Call Stability**: All call control functions now work correctly for both inbound and outbound scenarios
- **Enhanced Logging**: Comprehensive debugging for call relationship tracking
### Customer Number Detection Improvements (September 2025)
- **Voicemail Interface Fix**: Customer numbers now display correctly instead of showing "client:agentname" for browser phone calls
- **Call Recording Interface Fix**: Recording admin interface now shows actual customer phone numbers for all call types
- **Smart Number Detection**: Enhanced fallback logic retrieves customer numbers from call logs and parent call analysis
- **Browser Phone Support**: Proper handling of complex call topologies created by browser phone calls
- **User Experience**: Admin interfaces now consistently display meaningful customer information
### Browser Phone Upgrade (v2.0)
- **Migrated to Twilio Voice SDK v2**: Replaced deprecated Client SDK v1.14
- **Improved Stability**: Better error handling and automatic recovery
@@ -331,6 +345,19 @@ php test-sdk.php
- Review workflow step configuration
- Check notification_number field (not phone_number)
#### Outbound Call Control Issues
- **Customer Disconnections**: Fixed in latest version with call leg detection
- **Hold Not Working**: Ensure you have the latest version with `find_customer_call_leg()` function
- **Transfer Failures**: Check error logs for "Call Leg Detection" messages
- **Browser Phone Transfers**: Use latest version that supports `client:` identifier transfers
- **Requeue Problems**: Verify customer call leg is being used, not agent leg
#### Customer Number Display Issues
- **"client:agentname" in Voicemails**: Fixed in latest version with enhanced customer number detection
- **Wrong Numbers in Recording Interface**: Fixed with browser phone detection and call leg analysis
- **Missing Customer Info**: Check error logs for "TWP Voicemail Callback" or "TWP Recording" customer detection messages
- **Browser Phone Call Issues**: Enhanced detection now properly identifies real customer numbers in complex call topologies
#### SMS Not Sending from Admin
- Test with direct PHP script: `php test-twilio-direct.php send`
- Verify Twilio credentials in settings
@@ -413,7 +440,18 @@ All webhooks are REST API endpoints under `/wp-json/twilio-webhook/v1/`:
## Version History
### v2.1.0 (Current)
### v2.2.0 (Current - September 2025)
- **CRITICAL FIXES**: Resolved major outbound call issues
- **Call Leg Detection**: New intelligent system for complex call topologies
- **Customer Disconnection Fix**: Hold, transfer, and requeue now work correctly
- **Browser Phone Transfer Support**: Fixed `client:` identifier handling
- **Enhanced Debugging**: Comprehensive call relationship tracking
- **Outbound Call Stability**: All functions work for both inbound and outbound calls
- **Customer Number Detection**: Enhanced voicemail and recording interfaces to show real customer numbers
- **Browser Phone Interface Fixes**: Admin interfaces now properly identify customers in complex call scenarios
- **Fallback Logic**: Comprehensive customer number detection with call log and parent call analysis
### v2.1.0
- **Multiple Phone Numbers**: Workflows can now handle multiple phone numbers
- **Discord & Slack Integration**: Real-time notifications for call events
- **Enhanced Monitoring**: Automated queue timeout tracking and alerts