prefix . 'wpaic_conversations'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, user_ip varchar(100) NOT NULL, message text NOT NULL, reply text NOT NULL, context text NOT NULL, PRIMARY KEY (id) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); // Add default options if they don't exist if (!get_option('wpaic_welcome_message')) { update_option('wpaic_welcome_message', 'Hi! How can I help you today?'); } if (!get_option('wpaic_brand_color')) { update_option('wpaic_brand_color', '#007bff'); } if (!get_option('wpaic_chat_title')) { update_option('wpaic_chat_title', 'Sales Assistant'); } if (!get_option('wpaic_display_location')) { update_option('wpaic_display_location', 'all'); } if (!get_option('wpaic_contact_info')) { $default_info = "Or via email: contact@example.com"; update_option('wpaic_contact_info', $default_info); } } }