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:
@@ -338,6 +338,15 @@ class TWP_Webhooks {
|
||||
* Send SMS notification to agents about missed browser call
|
||||
*/
|
||||
private function send_agent_notification_sms($customer_number, $twilio_number) {
|
||||
// Send Discord/Slack notification for missed browser call
|
||||
require_once dirname(__FILE__) . '/class-twp-notifications.php';
|
||||
TWP_Notifications::send_call_notification('missed_call', array(
|
||||
'type' => 'missed_call',
|
||||
'caller' => $customer_number,
|
||||
'queue' => 'Browser Phone',
|
||||
'workflow_number' => $twilio_number
|
||||
));
|
||||
|
||||
// Get agents with phone numbers
|
||||
$agents = get_users(array(
|
||||
'meta_key' => 'twp_phone_number',
|
||||
@@ -556,6 +565,15 @@ class TWP_Webhooks {
|
||||
* Send SMS notification to agents about missed call
|
||||
*/
|
||||
private function send_missed_call_notification($customer_number, $twilio_number) {
|
||||
// Send Discord/Slack notification for missed call
|
||||
require_once dirname(__FILE__) . '/class-twp-notifications.php';
|
||||
TWP_Notifications::send_call_notification('missed_call', array(
|
||||
'type' => 'missed_call',
|
||||
'caller' => $customer_number,
|
||||
'queue' => 'General',
|
||||
'workflow_number' => $twilio_number
|
||||
));
|
||||
|
||||
// Get agents with phone numbers
|
||||
$agents = get_users(array(
|
||||
'meta_key' => 'twp_phone_number',
|
||||
|
Reference in New Issue
Block a user