SaleSave 30% on Pro with code WPIKO30See pricing →

Developer Hooks and Filters

Reading Time: 10 minutes
Download Markdown

Overview

WPiko AI Chatbot and WPiko AI Chatbot Pro provide WordPress filters and actions so developers can change behavior without editing plugin files. Add these snippets to a child theme’s functions.php or a small custom plugin.

Display and Loading

FilterUse it to
wpiko_chatbot_show_floating ($show)Show or hide the floating chatbot on the current page
wpiko_chatbot_load_frontend_assets ($load)Force-load (or prevent) the chatbot’s scripts and styles on a page, for example when you render the chatbot in a custom way
wpiko_chatbot_streaming_enabled ($enabled)Turn streaming replies off (default on)
wpiko_chatbot_style_presets ($presets)Add appearance presets to Chatbot Style
wpiko_chatbot_asset_version ($version)Change the version used for cache-busting assets
wpiko_chatbot_cache_monitored_options ($options)Add options that clear the cache when they change
wpiko_chatbot_admin_menu_shortcuts ($shortcuts)Change the shortcuts shown in the WordPress admin sidebar
// Hide the floating chatbot on the "checkout-help" page.
add_filter( 'wpiko_chatbot_show_floating', function ( $show ) {
    return is_page( 'checkout-help' ) ? false : $show;
} );

AI and Instructions

FilterUse it to
wpiko_chatbot_default_main_instructions ($instructions)Change the built-in default instructions used until the admin saves their own
wpiko_chatbot_managed_system_instructions ($instructions)Add or adjust plugin-managed instruction blocks
wpiko_chatbot_combined_instructions ($instructions)Change the final instructions sent to OpenAI
wpiko_chatbot_ai_feature_config ($config, $feature)Change the model, reasoning, output tokens, timeout or retries for helper features: translation, qa_generation, contact_enhancement
wpiko_chatbot_ai_feature_request_bodyAdjust the request body for those helper features
wpiko_chatbot_response_function_tools ($tools)Register extra function tools the AI can call
wpiko_chatbot_response_function_result ($result, $name, $arguments)Return the result for your custom function tool
wpiko_chatbot_skip_ai_response ($skip, $conversation_id)Skip the AI reply for a conversation (used by live takeover)
// Use a different model for conversation translation.
add_filter( 'wpiko_chatbot_ai_feature_config', function ( $config, $feature ) {
    if ( 'translation' === $feature ) {
        $config['model'] = 'gpt-5.6-luna';
    }
    return $config;
}, 10, 2 );

wpiko_chatbot_topic_focus_instructions ($rule) (filter, 2.1.3+) changes the short topic rule sent with every message when Topic focus is “Only questions about this website”. Return an empty string to send no rule.

Knowledge

HookUse it to
wpiko_chatbot_site_knowledge_page_limit (filter, default 10)Change how many pages Quick learn can include
wpiko_chatbot_site_knowledge_priority_words (filter)Change the words used to suggest the most useful pages first
wpiko_chatbot_site_knowledge_covered_pages (filter)Mark pages as already covered by another knowledge source (used by Scan Website)
wpiko_chatbot_pro_scan_post_types ($types) (filter, Pro 2.1.2)Change which content types Scan Website lists and processes
wpiko_chatbot_pro_scan_mode ($mode, $post) (filter, Pro 2.1.2)Return qa (AI-written Q&A) or markdown (clean Markdown, no AI) for an item. Default: qa for pages, markdown for everything else
wpiko_chatbot_pro_markdown_header ($lines, $post) (filter, Pro 2.1.2)Change the header lines (title, link, type, dates, terms) of Markdown files
wpiko_chatbot_pro_scan_excluded_ids ($ids) (filter, Pro 2.1.2)Hide more items from Scan Website. Default: WooCommerce Cart, Checkout, My account and Shop pages
wpiko_chatbot_pro_scan_pages_limit (filter, Pro 2.1.2, default 500)Change how many items of each content type are listed
wpiko_chatbot_pro_auto_sync_delay (filter, Pro 2.1.2, default 60)Seconds to wait after a post or doc is saved before updating the knowledge base
wpiko_chatbot_pro_auto_sync_batch (filter, Pro 2.1.2, default 5)How many items each automatic update run processes
wpiko_chatbot_qa_chunk_threshold, _chunk_size, _chunk_overlap (filters, Pro)Tune how large pages are split for Scan Website Q&A
wpiko_chatbot_pro_qa_max_pairs (filter, Pro 2.1.2, default 50)Change the Q&A Builder pair limit (also enforced on the server)
wpiko_chatbot_product_sync_batch_size (filter, Pro, default 20)Change how many products are processed per web sync batch
wpiko_chatbot_responses_file_deleted (action, $file_id)Run code when a knowledge file is deleted
wpiko_chatbot_responses_vector_store_deleted (action)Run code when the knowledge base is deleted
// Scan a "faq" custom post type as AI-written Q&A instead of Markdown.
add_filter( 'wpiko_chatbot_pro_scan_mode', function ( $mode, $post ) {
    return 'faq' === $post->post_type ? 'qa' : $mode;
}, 10, 2 );

Admin Screens and Dashboard

Since 2.1.2, every admin screen comes from one registry, and the same list builds the sidebar on desktop and the menu on phones. Add-ons can add screens, groups and Dashboard chips:

HookUse it to
wpiko_chatbot_admin_tabs ($tabs) (filter)Add a screen. Keys: label, icon (Dashicons class), group (monitor, ai, chat_widget, leads_sales, advanced or more), order, capability, pro (shows a PRO badge), section and section_label (join a sidebar entry that has sub-tabs), and nav (false = reachable by URL only, 'footer' = small link at the bottom of the sidebar)
wpiko_chatbot_admin_tab_groups ($groups) (filter)Add or reorder sidebar groups (label, order)
wpiko_chatbot_admin_nav_sections ($sections) (filter)Add a sidebar entry that combines several screens behind sub-tabs (label, icon, group, order)
wpiko_chatbot_admin_tab_registry ($tabs) (filter)Change the final list of screens, including the built-in ones
wpiko_chatbot_admin_tab_content ($tab) (filter)Print your screen’s content. Return true when you handled the tab, otherwise return $tab unchanged
wpiko_chatbot_admin_menu_shortcuts ($shortcuts) (filter)Change the shortcuts shown in the WordPress admin sidebar (default: Dashboard, Conversations, Settings)
wpiko_chatbot_dashboard_features ($features) (filter)Add On/Off chips to the Dashboard’s Configuration status. Each item: label, on, url, and optionally pro, locked, state ('warn'), state_label (text shown instead of On/Off, such as “24 hours”) and tooltip (2.1.4+, hover text for short labels)
wpiko_chatbot_dashboard_config_status (action)Older way to add rows to Configuration status. Still supported
// Add a "My Add-on" screen to the Advanced group.
add_filter( 'wpiko_chatbot_admin_tabs', function ( $tabs ) {
    $tabs['my_addon'] = array(
        'label' => 'My Add-on',
        'icon'  => 'dashicons-admin-plugins',
        'group' => 'advanced',
        'order' => 30,
    );
    return $tabs;
} );

// Print its content. Pass any other tab on unchanged.
add_filter( 'wpiko_chatbot_admin_tab_content', function ( $tab ) {
    if ( 'my_addon' !== $tab ) {
        return $tab;
    }
    echo '<h1>My Add-on</h1>';
    return true;
} );

// Show a chip on the Dashboard.
add_filter( 'wpiko_chatbot_dashboard_features', function ( $features ) {
    $features['my_addon'] = array(
        'label' => 'My Add-on',
        'on'    => (bool) get_option( 'my_addon_enabled' ),
        'url'   => admin_url( 'admin.php?page=ai-chatbot&tab=my_addon' ),
    );
    return $features;
} );

Admin Popups

The Train AI popups share one shell. Use it for your own admin popups so they get the same header, scrolling body, footer, keyboard support and unsaved-changes warning:

  • wpiko_chatbot_render_modal( $args ) (PHP): prints the popup. Arguments: id, container_id (element that receives your content), title, description, icon, badge and size (default or wide). Wrap actions in <div class="wpiko-modal-footer-slot"> to place them in the footer.
  • window.wpikoModal (JavaScript): open, close, load, setDirty (mark unsaved changes, so closing asks first), setGuard (ask before closing while work runs), isDirty and confirm (a styled confirmation dialog that returns a promise).

Usage and Cost

Since 2.1.4, the plugin records the tokens of each OpenAI request and estimates its cost for the Dashboard’s AI usage & cost card. Prices are in US dollars per 1 million tokens.

HookUse it to
wpiko_chatbot_model_prices ($prices) (filter)Change or add model prices. Keys are model IDs (dated snapshots use the closest match); each value has input, cached and output, and optionally promo with an until date (YYYY-MM-DD) and its own prices. Use it for custom pricing, or for a model the plugin doesn’t know yet: its tokens are counted, but its cost is left out until it has a price.
wpiko_chatbot_file_search_call_price ($price) (filter)Change the price of one knowledge search (default 0.0025, that is $2.50 per 1,000 searches)
wpiko_chatbot_usage_sources ($sources) (filter)Change the features listed under “by feature” (key => label). Pro features are only listed when Pro is active
wpiko_chatbot_usage_retention_days ($days) (filter, default 400)Change how long usage records are kept. The minimum is 62 days, so this month and last month always stay complete
wpiko_chatbot_usage_recorded ($row) (action)Run code after a request’s usage is saved, for example to send it to your own reporting. $row has the source, model, session ID, token counts, search calls and cost; never the message text
// Estimate GPT-6 Luna with your negotiated price.
add_filter( 'wpiko_chatbot_model_prices', function ( $prices ) {
    $prices['gpt-6-luna'] = array(
        'input'  => 0.08,
        'cached' => 0.008,
        'output' => 0.40,
    );
    return $prices;
} );

Visitors and Limits

FilterUse it to
wpiko_chatbot_client_ip ($ip)Read the real visitor IP behind a proxy or CDN (used by User Limits and order lookup limits). Return a valid IP address: since 2.1.1, chat requests without a valid IP are blocked.
wpiko_chatbot_user_limit_bypass ($bypass, $conversation_id)Skip your custom hourly and daily User Limits for certain visitors, such as logged-in customers. Since 2.1.1, the safety limits (10 per minute, 60 per hour, 300 per day per IP) and the site-wide daily limit still apply.
wpiko_chatbot_lookup_order_id ($order_id, $order_number) (Pro)Map custom order numbers to WooCommerce order IDs for Order Assistance
// Behind Cloudflare: use the visitor's real IP.
add_filter( 'wpiko_chatbot_client_ip', function ( $ip ) {
    if ( ! empty( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) {
        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CF_CONNECTING_IP'] ) );
    }
    return $ip;
} );

// Skip the custom hourly and daily limits for logged-in users.
// Safety limits and the site-wide daily limit still apply.
add_filter( 'wpiko_chatbot_user_limit_bypass', function ( $bypass ) {
    return is_user_logged_in() ? true : $bypass;
} );

Only trust forwarded headers when your site really is behind that proxy. Otherwise visitors could fake their IP.

Conversation Memory and Takeover

HookUse it to
wpiko_chatbot_conversation_memory_days ($days) (filter, 2.1.3+)Change how many days a conversation is remembered after its last message. 0 = only while the browser tab is open. Values above 30 are lowered to 30. See Conversation Memory.
wpiko_chatbot_pro_takeover_auto_release_hours ($hours) (filter, Pro 2.1.3+)Change how long a takeover stays active without team activity before it goes back to the AI (default 12). 0 = never.
window.wpikoChatbotStore (JavaScript, 2.1.3+)Read and write the visitor’s conversation wherever the setting keeps it: get(key), set(key, value), remove(key), clearConversation(), isPersistent(), isExpired() and onChange(callback) (another tab changed the conversation). Use it instead of reading sessionStorage directly.
// Remember conversations for 14 days after the last message.
add_filter( 'wpiko_chatbot_conversation_memory_days', function ( $days ) {
    return 14;
} );

// Hand forgotten takeovers back to the AI after 4 hours instead of 12.
add_filter( 'wpiko_chatbot_pro_takeover_auto_release_hours', function ( $hours ) {
    return 4;
} );

Other Actions

  • wpiko_chatbot_message_saved ($user_id, $thread_id, $role, $message, $user_email): after a chat message is saved, for example to send it to a CRM.
  • wpiko_chatbot_conversation_deleted ($session_id): after a conversation is deleted.
  • wpiko_chatbot_before_chat_request: before a chat request is processed.
  • wpiko_chatbot_enqueue_frontend_assets: when the chatbot’s frontend assets are loaded. Enqueue your own chatbot add-on scripts here.
  • wpiko_chatbot_menu_items: add items to the chat window’s menu.
  • wpiko_chatbot_pro_takeover_auto_released ($session_id, $admin_id) (Pro 2.1.3+): after a takeover went back to the AI because nobody from the team replied to or opened it for 12 hours.

Hooks not listed here are internal and may change between versions.