Fix urgent voicemail SMS from number and add Discord/Slack notifications
- Fix SMS notifications to use Default SMS From Number instead of destination - Add Discord webhook notifications for urgent keyword voicemails - Add Slack webhook notifications for urgent keyword voicemails - Make notification methods public to allow external calls - Add urgent_voicemail type support with custom formatting - Include transcription, keyword, and admin link in notifications - Use bright red color for urgent alerts in both Discord and Slack 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1383,10 +1383,39 @@ class TWP_Webhooks {
|
||||
|
||||
// Also send urgent SMS notification
|
||||
$notification_number = get_option('twp_sms_notification_number');
|
||||
if ($notification_number) {
|
||||
$default_sms_from = get_option('twp_default_sms_number');
|
||||
|
||||
if ($notification_number && $default_sms_from) {
|
||||
$twilio = new TWP_Twilio_API();
|
||||
$sms_message = "URGENT voicemail from {$from_number}. Keyword: {$keyword}. Check admin panel immediately.";
|
||||
$twilio->send_sms($notification_number, $sms_message);
|
||||
// Explicitly pass the Default SMS From Number as the third parameter
|
||||
$twilio->send_sms($notification_number, $sms_message, $default_sms_from);
|
||||
}
|
||||
|
||||
// Send Discord notification if configured
|
||||
$discord_webhook = get_option('twp_discord_webhook_url');
|
||||
if ($discord_webhook) {
|
||||
TWP_Notifications::send_discord_notification($discord_webhook, array(
|
||||
'type' => 'urgent_voicemail',
|
||||
'from_number' => $from_number,
|
||||
'keyword' => $keyword,
|
||||
'transcription' => $transcription_text,
|
||||
'voicemail_id' => $voicemail_id,
|
||||
'admin_url' => admin_url('admin.php?page=twilio-wp-voicemails')
|
||||
));
|
||||
}
|
||||
|
||||
// Send Slack notification if configured
|
||||
$slack_webhook = get_option('twp_slack_webhook_url');
|
||||
if ($slack_webhook) {
|
||||
TWP_Notifications::send_slack_notification($slack_webhook, array(
|
||||
'type' => 'urgent_voicemail',
|
||||
'from_number' => $from_number,
|
||||
'keyword' => $keyword,
|
||||
'transcription' => $transcription_text,
|
||||
'voicemail_id' => $voicemail_id,
|
||||
'admin_url' => admin_url('admin.php?page=twilio-wp-voicemails')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user