Hooks - PHP

Below you'll find a list of all available PHP hooks that can be used to extend or adjust the functionality of the plugin.

settings

This filter allows adjusting the global settings before they are being applied.

            add_filter('sleekAi/settings', function ($settings) {
      $settings['altText']['autoGenerate'] = true;
      $settings['altText']['fields'] = ['alt', 'caption', 'description'];

      return $$settings;
    });
  
                    
Copy

polling

This filter allows forcing polling mode for streaming responses, even if the server supports Server-Sent Events (SSE).

            // Force polling mode
    add_filter('sleekAi/polling', '__return_true');

    // Force streaming mode (only if you know SSE works)
    add_filter('sleekAi/polling', '__return_false');
  
                    
Copy

By default, SleekAI automatically detects whether streaming is supported and falls back to polling if not. Use this filter only if you need to override the automatic detection.

chatbot

This filter allows adjusting the chatbot data before it is being rendered.

            add_filter('sleekAi/chatbot', function ($chatbot) {
      $chatbot['data']['instruction'] .= 'Only answer in unformatted text, no code blocks.';

      return $render;
    });
  
                    
Copy

chatbot/conditions

This filter allows adding custom conditions to show or hide a chatbot.

            add_filter('sleekAi/chatbot/conditions', function ($data) {
      $data[] = [
        'id'    => 'isCustomUrl',
        'label' => 'Custom URL Check',
        'value' => str_contains($_SERVER['REQUEST_URI'], '?customParam'),
      ];

      return $data;
    });
  
                    
Copy

chatbot/id

This filter allows adjusting the chatbot data by ID before it is being rendered.

            add_filter('sleekAi/chatbot/id=1', function ($chatbot) {
      $chatbot['data']['instruction'] .= 'Only answer in unformatted text, no code blocks.';

      return $render;
    });
  
                    
Copy

chatbot/key

This filter allows adjusting the chatbot data by key before it is being rendered.

            add_filter('sleekAi/chatbot/key=my-chatbot', function ($chatbot) {
      $chatbot['data']['instruction'] .= 'Only answer in unformatted text, no code blocks.';

      return $render;
    });
  
                    
Copy

chatbot/markup

This filter allows adjusting the markup that is being rendered for the chatbot.

            add_filter('sleekAi/chatbot/markup', function ($markup) {
      $markup .= '<style>
        :root {
          --sleek-ai--chatbot-button--background-color: #FFFFFF;
          --sleek-ai--chatbot-button--border-color: #E4E4E7;
          --sleek-ai--chatbot-button--border-radius: 8px;
          --sleek-ai--chatbot-button--box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
          --sleek-ai--chatbot-button--color: #000000;
          --sleek-ai--chatbot-button--distance: 16px;
          --sleek-ai--chatbot-button--font-size: 0.875rem;
          --sleek-ai--chatbot-button--font-weight: 500;
          --sleek-ai--chatbot-button--line-height: 1;
          --sleek-ai--chatbot-button--padding: 12px 16px;
          --sleek-ai--chatbot-button--position: fixed;
        }
      </style>';

      return $markup;
    });
  
                    
Copy

For more information on how to use the markup filter, please refer to the documentation.

chatbot/sources

This filter allows adding custom sources to the chatbot.

            add_filter('sleekAi/chatbot/sources', function ($data) {
      $data[] = [
        'id'    => 'customSource',
        'label' => 'Custom Source',
        'value' => functionToGetCustomData(),
      ];

      return $data;
    });
  
                    
Copy