'sanitize_text_field', ]); register_setting('aiar_light_settings', 'aiar_light_disable_ai', [ 'sanitize_callback' => 'absint', // stores as 0 or 1 ]); register_setting('aiar_light_settings', 'aiar_light_business_description', [ 'sanitize_callback' => 'wp_kses_post', // allows safe HTML ]); register_setting('aiar_light_settings', 'aiar_light_selected_form', [ 'sanitize_callback' => 'sanitize_text_field', ]); }); function aiarlight_enqueue_admin_styles( $hook ) { // Only load on your plugin's admin page (slug = aiar-light) if ( $hook !== 'toplevel_page_aiar-light' ) { return; } // Google font (optional) wp_enqueue_style( 'inter-font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap', [], null ); // Your admin styles wp_enqueue_style( 'aiarlight-admin-style', plugin_dir_url( __FILE__ ) . 'css/admin-style.css', [], '1.0.0' ); } add_action( 'admin_enqueue_scripts', 'aiarlight_enqueue_admin_styles' ); // 2) Admin page with tabs function aiar_light_admin_page() { $allowed_tabs = ['settings', 'logs', 'pro', 'info']; // phpcs:disable WordPress.Security.NonceVerification.Recommended // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $tab_raw = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'settings'; $tab = in_array( $tab_raw, $allowed_tabs, true ) ? $tab_raw : 'settings'; // phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized // phpcs:enable WordPress.Security.NonceVerification.Recommended ?>

AI Auto Responder Light

No auto-reply emails will be sent while this is enabled.

Email From (Pro)
Select AI Model (Pro)
Custom Email Template (Pro)

The more complete and specific your description (even down to prices or case studies), the richer and more on-brand your AI replies will be.

Only Contact Form 7 is available in Light version.


DateEmailPromptResponse
No logs yet.

🚀 Upgrade to AI Auto Responder Pro

Unlock full power with:

Buy AI Auto Responder Pro →

Plugin Info & Tips

Version: 1.3.0

Ensure your CF7 forms have fields `your-email`, `your-name` and `your-message`

What it does: Sends AI-generated email replies via Contact Form 7, logs conversations, and previews Pro features.

How to write your Business Description

Tip: The more complete and specific your description (even down to prices or case studies), the richer and more on-brand your AI replies will be.



🚨 Disclaimer

AI Auto Responder Light is a tool that connects your WordPress site to AI services like OpenAI via your own API key.

You are responsible for:

The plugin developer is not liable for any issues, damages, or legal consequences resulting from plugin use or AI-generated content. Please consult legal counsel if needed.


🚀 Upgrade to AI Auto Responder Pro

Unlock full power with:

Buy AI Auto Responder Pro →

current_time( 'mysql' ), 'email' => sanitize_email( $email ), 'prompt' => $prompt, 'response' => $response, ]; if ( count( $logs ) > 20 ) { $logs = array_slice( $logs, -20 ); } update_option( 'aiar_light_conversation_logs', $logs ); } // 4) AI responder core function aiar_light_get_response( $prompt, $name = '' ) { $api_key = get_option( 'aiar_light_api_key', '' ); if ( ! $api_key || ! $prompt ) { return ''; } $company = get_bloginfo( 'name' ); $desc = get_option( 'aiar_light_business_description', '' ); // Build a system prompt that tells the AI to greet by name: $system = sprintf( "You are the official AI assistant for “%s”.\n\n" . "You know only what’s in the business description below:\n" . "—— DESCRIPTION ———\n%s\n—— END ———\n\n" . "When answering, always begin with a friendly greeting using the user's name (%s).\n" . "Be as detailed as possible (3–5 sentences). If you need more info, ask follow-up questions.\n" . "Answer in a friendly, professional tone, and mention “%s” in your reply.\n" . "If you don’t know the answer, say: “I’m sorry, I don’t have enough information to help with that.”", $company, $desc, $name ?: 'there', // fallback if no name provided $company ); $body = [ 'model' => 'gpt-3.5-turbo', 'messages' => [ [ 'role' => 'system', 'content' => $system ], [ 'role' => 'user', 'content' => $prompt ], ], ]; $response = wp_remote_post( 'https://api.openai.com/v1/chat/completions', [ 'headers' => [ 'Authorization' => 'Bearer ' . $api_key, 'Content-Type' => 'application/json', ], 'body' => wp_json_encode( $body ), ] ); if ( is_wp_error( $response ) ) { return ''; } $data = json_decode( wp_remote_retrieve_body( $response ), true ); return ! empty( $data['choices'][0]['message']['content'] ) ? trim( $data['choices'][0]['message']['content'] ) : ''; } // 5) CF7 integration add_action( 'wpcf7_mail_sent', function( $contact_form ) { if ( get_option( 'aiar_light_selected_form', 'cf7' ) !== 'cf7' ) { return; } $submission = WPCF7_Submission::get_instance(); if ( ! $submission ) { return; } $data = $submission->get_posted_data(); $email = sanitize_email( $data['your-email'] ?? '' ); $msg = sanitize_text_field( $data['your-message'] ?? '' ); $name = sanitize_text_field( $data['your-name'] ?? '' ); // grab the name if ( ! $email || ! $msg ) { return; } if ( get_option( 'aiar_light_disable_ai' ) ) { return; } // 1) Get AI response $ai = aiar_light_get_response( $msg, $name ); if ( ! $ai ) { return; } // 2) Log with the email aiar_light_log_conversation( $msg, $ai, $email ); // 3) Send the email $company = sanitize_text_field( get_bloginfo( 'name' ) ); $from_email = get_option( 'admin_email' ); $headers = [ "From: {$company} <{$from_email}>", "Reply-To: {$from_email}", "Content-Type: text/html; charset=UTF-8", ]; $message = '

' . nl2br( esc_html( $ai ) ) . '

'; wp_mail( $email, "Reply from {$company}", $message, $headers ); }); // Privacy: Exporter & eraser add_filter( 'wp_privacy_personal_data_exporters', function( $exporters ) { $exporters['aiar-light-logs'] = [ 'exporter_friendly_name' => __( 'AI Auto Responder Logs','ai-auto-responder-light' ), 'callback' => 'aiar_light_export_logs', ]; return $exporters; } ); function aiar_light_export_logs( $email_address ) { $data = get_option( 'aiar_light_conversation_logs', [] ); $export_items = []; foreach ( $data as $entry ) { if ( ! empty( $entry['email'] ) && $entry['email'] === $email_address ) { $export_items[] = [ 'group_id' => 'aiar-light-logs', 'group_label' => __( 'AI Auto Responder Conversations','ai-auto-responder-light' ), 'item_id' => uniqid( 'aiar_log_' ), 'data' => [ __( 'Date','ai-auto-responder-light' ) => $entry['time'], __( 'Prompt','ai-auto-responder-light' ) => $entry['prompt'], __( 'Response','ai-auto-responder-light' ) => $entry['response'], ], ]; } } return [ 'data' => $export_items, 'done' => true ]; } add_filter( 'wp_privacy_personal_data_erasers', function( $erasers ) { $erasers['aiar-light-logs'] = [ 'eraser_friendly_name' => __( 'AI Auto Responder Logs','ai-auto-responder-light' ), 'callback' => 'aiar_light_erase_logs', ]; return $erasers; } ); function aiar_light_erase_logs( $email_address ) { $data = get_option( 'aiar_light_conversation_logs', [] ); $new = array_filter( $data, function( $entry ) use ( $email_address ) { return empty( $entry['email'] ) || $entry['email'] !== $email_address; } ); update_option( 'aiar_light_conversation_logs', array_values( $new ) ); return [ 'items_removed' => count( $data ) - count( $new ), 'items_retained' => count( $new ), 'messages' => [], 'done' => true, ]; } ?>