Developer Hooks and Filters

Reading Time: 4 minutes
Download Markdown

Overview

WPiko Chatbot and WPiko 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 );

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_qa_chunk_threshold, _chunk_size, _chunk_overlap (filters, Pro)Tune how large pages are split for Scan Website
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

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.

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.

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

Have a Question?