From aa58b4550134705adea2afbc6c98cad59f4c444b Mon Sep 17 00:00:00 2001 From: jknapp Date: Wed, 13 Aug 2025 10:35:21 -0700 Subject: [PATCH] Implement multiple phone numbers per workflow feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Database Changes: - Added twp_workflow_phones junction table for many-to-many relationship - Updated activator to create and manage new table - Maintained backward compatibility with existing phone_number field Workflow Management: - Added set_workflow_phone_numbers() and get_workflow_phone_numbers() methods - Updated get_workflow_by_phone_number() to check both old and new structures - Enhanced save/update handlers to support phone_numbers array - Added AJAX endpoint for retrieving workflow phone numbers User Interface: - Replaced single phone number select with dynamic multi-select interface - Added "Add Number" and "Remove" buttons for managing multiple numbers - Updated workflow listing to display all assigned phone numbers - Enhanced JavaScript for phone number management and validation The webhook routing already supports multiple numbers since get_workflow_by_phone_number() was updated to check both structures. This feature allows users to assign multiple Twilio phone numbers to trigger the same workflow. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- admin/class-twp-admin.php | 71 ++++++++++++++++++--- assets/js/admin.js | 102 +++++++++++++++++++++++++++++-- includes/class-twp-activator.php | 17 +++++- includes/class-twp-core.php | 1 + includes/class-twp-workflow.php | 82 ++++++++++++++++++++++++- 5 files changed, 254 insertions(+), 19 deletions(-) diff --git a/admin/class-twp-admin.php b/admin/class-twp-admin.php index ce19b5c..f2b32f0 100644 --- a/admin/class-twp-admin.php +++ b/admin/class-twp-admin.php @@ -1476,10 +1476,14 @@ class TWP_Admin { foreach ($workflows as $workflow) { $workflow_data = json_decode($workflow->workflow_data, true); $step_count = isset($workflow_data['steps']) ? count($workflow_data['steps']) : 0; + + // Get phone numbers for this workflow + $phone_numbers = TWP_Workflow::get_workflow_phone_numbers($workflow->id); + $phone_display = !empty($phone_numbers) ? implode(', ', $phone_numbers) : $workflow->phone_number; ?> workflow_name); ?> - phone_number); ?> + steps @@ -1510,11 +1514,17 @@ class TWP_Admin {
- - + +
+
+ + +
+
+

You can assign multiple phone numbers to this workflow. All selected numbers will trigger this workflow when called.