Implement Discord and Slack notifications for call events
Settings & Configuration: - Added Discord webhook URL, Slack webhook URL settings in admin - Added notification type toggles (incoming calls, queue timeouts, missed calls) - Added queue timeout threshold setting (30-1800 seconds) - Registered all new settings with WordPress options system Notification System: - Created TWP_Notifications class for Discord/Slack webhook handling - Rich message formatting with embeds/attachments for both platforms - Color-coded notifications (blue=incoming, yellow=timeout, red=missed) - Comprehensive error handling and logging Integration Points: - Incoming calls: Notifications sent when calls enter queues - Queue timeouts: Automated monitoring via cron job (every minute) - Missed calls: Notifications for browser phone and general missed calls - Added notified_timeout column to prevent duplicate timeout notifications Features: - Professional Discord embeds with fields and timestamps - Slack attachments with proper formatting and colors - Automatic cron job setup for queue timeout monitoring - Fallback to SMS notifications while Discord/Slack also work - Configurable notification types and timeout thresholds This provides real-time call notifications to Discord channels and Slack channels, helping teams stay informed about incoming calls and queue issues even when SMS notifications aren't working due to validation delays. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -167,6 +167,10 @@ class TWP_Core {
|
||||
|
||||
// Agent queue management AJAX
|
||||
$this->loader->add_action('wp_ajax_twp_accept_call', $plugin_admin, 'ajax_accept_call');
|
||||
|
||||
// Discord/Slack notification system
|
||||
$this->loader->add_action('init', $this, 'setup_notification_cron');
|
||||
$this->loader->add_action('twp_check_queue_timeouts', $this, 'check_queue_timeouts');
|
||||
$this->loader->add_action('wp_ajax_twp_accept_next_queue_call', $plugin_admin, 'ajax_accept_next_queue_call');
|
||||
$this->loader->add_action('wp_ajax_twp_get_waiting_calls', $plugin_admin, 'ajax_get_waiting_calls');
|
||||
$this->loader->add_action('wp_ajax_twp_set_agent_status', $plugin_admin, 'ajax_set_agent_status');
|
||||
@@ -385,4 +389,21 @@ class TWP_Core {
|
||||
error_log("TWP Cleanup: Updated {$updated_waiting} old waiting calls to 'timeout' status");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup notification cron job
|
||||
*/
|
||||
public function setup_notification_cron() {
|
||||
if (!wp_next_scheduled('twp_check_queue_timeouts')) {
|
||||
wp_schedule_event(time(), 'twp_every_minute', 'twp_check_queue_timeouts');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for queue timeouts and send notifications
|
||||
*/
|
||||
public function check_queue_timeouts() {
|
||||
require_once dirname(__FILE__) . '/class-twp-notifications.php';
|
||||
TWP_Notifications::check_queue_timeouts();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user