code push

This commit is contained in:
2025-08-07 15:24:29 -07:00
parent b5e091d845
commit 3b499e2074
15 changed files with 1225 additions and 232 deletions

View File

@@ -232,17 +232,13 @@ class TWP_Callback_Manager {
* Handle outbound agent answered
*/
public static function handle_outbound_agent_answered($target_number, $agent_call_sid) {
$twilio = new TWP_Twilio_API();
// Create TwiML to call the target number
$twiml = new \Twilio\TwiML\VoiceResponse();
$twiml->say('Connecting your call...', ['voice' => 'alice']);
$dial = $twiml->dial([
'callerId' => get_option('twp_caller_id_number', ''), // Use configured caller ID
$twiml->dial($target_number, [
'callerId' => get_option('twp_caller_id_number', ''),
'timeout' => 30
]);
$dial->number($target_number);
// If no answer, leave a message
$twiml->say('The number you called is not available. Please try again later.', ['voice' => 'alice']);
@@ -259,7 +255,10 @@ class TWP_Callback_Manager {
$gather = $twiml->gather([
'numDigits' => 1,
'timeout' => 10,
'action' => home_url('/wp-json/twilio-webhook/v1/callback-choice'),
'action' => home_url('/wp-json/twilio-webhook/v1/callback-choice?' . http_build_query([
'queue_id' => $queue_id,
'phone_number' => $caller_number
])),
'method' => 'POST'
]);