Fix extension transfer system and browser phone compatibility

Major Fixes:
- Fixed extension transfers going directly to voicemail for available agents
- Resolved browser phone call disconnections during transfers
- Fixed voicemail transcription placeholder text issue
- Added Firefox compatibility with automatic media permissions

Extension Transfer Improvements:
- Changed from active client dialing to proper queue-based system
- Fixed client name generation consistency (user_login vs display_name)
- Added 2-minute timeout with automatic voicemail fallback
- Enhanced agent availability detection for browser phone users

Browser Phone Enhancements:
- Added automatic microphone/speaker permission requests
- Improved Firefox compatibility with explicit getUserMedia calls
- Fixed client naming consistency across capability tokens and call acceptance
- Added comprehensive error handling for permission denials

Database & System Updates:
- Added auto_busy_at column for automatic agent status reversion
- Implemented 1-minute auto-revert system for busy agents with cron job
- Updated database version to 1.6.2 for automatic migration
- Fixed voicemail user_id association for extension voicemails

Call Statistics & Logging:
- Fixed browser phone calls not appearing in agent statistics
- Enhanced call logging with proper agent_id association in JSON format
- Improved customer number detection for complex call topologies
- Added comprehensive debugging for call leg detection

Voicemail & Transcription:
- Replaced placeholder transcription with real Twilio API integration
- Added manual transcription request capability for existing voicemails
- Enhanced voicemail callback handling with user_id support
- Fixed transcription webhook processing for extension voicemails

Technical Improvements:
- Standardized client name generation across all components
- Added ElevenLabs TTS integration to agent connection messages
- Enhanced error handling and logging throughout transfer system
- Fixed TwiML generation syntax errors in dial() methods

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-02 11:03:33 -07:00
parent ae92ea2c81
commit 7cd7f036ff
14 changed files with 1312 additions and 194 deletions

View File

@@ -16,7 +16,7 @@ if (!defined('WPINC')) {
// Plugin constants
define('TWP_VERSION', '2.4.2');
define('TWP_DB_VERSION', '1.6.0'); // Track database version separately
define('TWP_DB_VERSION', '1.6.2'); // Track database version separately
define('TWP_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('TWP_PLUGIN_URL', plugin_dir_url(__FILE__));
define('TWP_PLUGIN_BASENAME', plugin_basename(__FILE__));
@@ -67,8 +67,13 @@ function twp_sdk_missing_notice() {
if (is_admin()) {
add_action('admin_init', 'twp_check_sdk_installation');
add_action('admin_init', 'twp_check_database_updates');
add_action('admin_init', 'twp_setup_auto_revert_cron');
}
// Hook up cron functions
add_filter('cron_schedules', 'twp_add_cron_interval');
add_action('twp_auto_revert_agents', 'twp_handle_auto_revert_agents');
/**
* Check and perform database updates if needed
*/
@@ -82,6 +87,34 @@ function twp_check_database_updates() {
}
}
/**
* Setup auto-revert cron job for agent status
*/
function twp_setup_auto_revert_cron() {
if (!wp_next_scheduled('twp_auto_revert_agents')) {
wp_schedule_event(time(), 'twp_every_minute', 'twp_auto_revert_agents');
}
}
/**
* Handle auto-revert cron job
*/
function twp_handle_auto_revert_agents() {
require_once TWP_PLUGIN_DIR . 'includes/class-twp-agent-manager.php';
TWP_Agent_Manager::revert_auto_busy_agents();
}
/**
* Add custom cron schedule
*/
function twp_add_cron_interval($schedules) {
$schedules['twp_every_minute'] = array(
'interval' => 60, // Every 60 seconds
'display' => esc_html__('Every Minute (TWP)', 'twilio-wp-plugin')
);
return $schedules;
}
/**
* Plugin deactivation hook
*/