Add queue timeout voicemail and Amazon SNS SMS provider support
This update adds two major features: 1. Queue Timeout Voicemail - Callers can now leave voicemail when queue timeout is reached - Configurable per-queue voicemail prompts with TTS support - Automatic transcription and urgent keyword detection - Admin setting to choose between voicemail or callback on timeout 2. Amazon SNS SMS Provider - Alternative SMS provider to Twilio for sending text messages - Useful when Twilio SMS approval is difficult to obtain - Provider abstraction layer allows switching between Twilio/SNS - Full AWS SNS configuration in admin settings - Supports custom sender IDs in compatible countries - Lower cost per SMS compared to Twilio New Files: - includes/class-twp-voicemail-handler.php - Voicemail recording handler - includes/interface-twp-sms-provider.php - SMS provider interface - includes/class-twp-sms-provider-twilio.php - Twilio SMS implementation - includes/class-twp-sms-provider-sns.php - Amazon SNS implementation - includes/class-twp-sms-manager.php - SMS provider abstraction manager - QUEUE_VOICEMAIL_SMS_FEATURES.md - Complete feature documentation Modified Files: - includes/class-twp-call-queue.php - Added voicemail option to timeout handler - includes/class-twp-twilio-api.php - Updated send_sms() to use provider abstraction - admin/class-twp-admin.php - Added SMS provider and timeout action settings - composer.json - Added AWS SDK dependency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -168,7 +168,7 @@ class TWP_Call_Queue {
|
||||
private function handle_timeout($call, $queue) {
|
||||
global $wpdb;
|
||||
$table_name = $wpdb->prefix . 'twp_queued_calls';
|
||||
|
||||
|
||||
// Update status
|
||||
$wpdb->update(
|
||||
$table_name,
|
||||
@@ -180,15 +180,36 @@ class TWP_Call_Queue {
|
||||
array('%s', '%s'),
|
||||
array('%d')
|
||||
);
|
||||
|
||||
// Offer callback instead of hanging up
|
||||
$callback_twiml = TWP_Callback_Manager::create_callback_twiml($queue->id, $call->from_number);
|
||||
|
||||
|
||||
// Get timeout action preference (default to voicemail)
|
||||
$timeout_action = get_option('twp_queue_timeout_action', 'voicemail');
|
||||
|
||||
$twilio = new TWP_Twilio_API();
|
||||
$twilio->update_call($call->call_sid, array(
|
||||
'twiml' => $callback_twiml
|
||||
));
|
||||
|
||||
|
||||
if ($timeout_action === 'voicemail') {
|
||||
// Offer voicemail recording
|
||||
require_once dirname(__FILE__) . '/class-twp-voicemail-handler.php';
|
||||
$voicemail_twiml = TWP_Voicemail_Handler::create_voicemail_twiml(
|
||||
$call->from_number,
|
||||
$queue->id
|
||||
);
|
||||
|
||||
$twilio->update_call($call->call_sid, array(
|
||||
'twiml' => $voicemail_twiml
|
||||
));
|
||||
|
||||
error_log("TWP Queue Timeout: Directing call {$call->call_sid} to voicemail");
|
||||
} else {
|
||||
// Offer callback (original behavior)
|
||||
$callback_twiml = TWP_Callback_Manager::create_callback_twiml($queue->id, $call->from_number);
|
||||
|
||||
$twilio->update_call($call->call_sid, array(
|
||||
'twiml' => $callback_twiml
|
||||
));
|
||||
|
||||
error_log("TWP Queue Timeout: Offering callback to {$call->from_number}");
|
||||
}
|
||||
|
||||
// Reorder queue
|
||||
self::reorder_queue($queue->id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user