Implement bridged forwarding with agent call control features

Major enhancement to workflow forwarding that solves voicemail issues and adds agent call control capabilities.

Key improvements:
- Converted direct forwarding to bridged forwarding to avoid self-call voicemail issues
- Added DTMF-based agent features during calls:
  * *9 - Hold/Unhold customer
  * *0 - Start/Stop call recording
  * *5 - Transfer to another extension
  * *1 - Mute/Unmute (placeholder for future conference mode)
- Added webhook handlers for agent features and forward results
- Agent features URL attached to Number elements for DTMF detection
- Continuous DTMF listening during active calls
- Proper call leg detection for hold/resume operations

Technical details:
- Added /agent-features webhook for DTMF capture
- Added /agent-action webhook for processing commands
- Added /forward-result webhook for handling dial outcomes
- Modified append_twiml_element to preserve Number attributes (url, method)
- Enhanced logging throughout for debugging

This eliminates the issue where calling yourself would go straight to voicemail and provides professional call control features for agents.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-18 18:29:20 -07:00
parent 0ee8210fef
commit e475e68a5f
5 changed files with 310 additions and 840 deletions

View File

@@ -4945,7 +4945,7 @@ class TWP_Admin {
}
$voice_id = sanitize_text_field($_POST['voice_id']);
$text = sanitize_text_field($_POST['text']) ?: 'Hello, this is a preview of this voice.';
$text = isset($_POST['text']) ? sanitize_text_field($_POST['text']) : 'Hello, this is a preview of this voice.';
$elevenlabs = new TWP_ElevenLabs_API();
$result = $elevenlabs->text_to_speech($text, $voice_id);