Skip to content

Hooks

SleekAI fires these hooks for site code. Each is documented by the @api docblock on the apply_filters or do_action call that fires it; a hook without one is internal and may change without notice.

sleekAi/altText/generate

Action, fired in product/includes/classes/AltText.php.

Generates the alt text of an uploaded image. Sleek AI queues it in Action Scheduler, group sleek-ai, when an image is uploaded while automatic generation is on, and handles it at the default priority; when it cannot be queued, the text is generated during the upload.

Parameter Type Description
$attachmentId int The uploaded image’s attachment ID.

sleekAi/chatbot/budget

Filter, fired in product/includes/classes/Rest/Completions.php.

How many messages all visitors together may send one chatbot in an hour and in a day. The hour starts on the hour and the day at midnight UTC; once either budget is used up, further messages are refused until its window ends. Requests from administrators are not counted.

Parameter Type Description
$budget array The limits by window: hour 200 and day 1000 by default; a missing window keeps its default and 0 or less removes it.
$scope array The chatbot the request is for: its chatbotId, or the chatbotKey of one rendered with sleekAi_render_chatbot().

Returns array The limits by window.

sleekAi/chatbot/conditions

Filter, fired in product/includes/classes/Chatbot/Chatbot.php.

Adds conditions to the chatbot display rules. The editor lists each entry by its label, and a rule compares the entry’s value, computed while the page renders, with == or !=. A rule that names an entry the filter no longer returns fails its group.

Parameter Type Description
$conditions array Conditions added so far, each an array with an id, a label and a value; an id that starts with is or has makes a yes-or-no condition.

Returns array The conditions to offer.

sleekAi/chatbot/id=*/markup

Filter, fired in product/includes/classes/Chatbot/Chatbot.php.

Filters the markup of one saved chatbot, by its post ID, after sleekAi/chatbot/markup.

Parameter Type Description
$markup string|false The markup so far.
$chatbot array The chatbot’s settings.

Returns string|false Markup to insert into the chatbot’s frame.

sleekAi/chatbot/key=*/markup

Filter, fired in product/includes/classes/Chatbot/Chatbot.php.

Filters the markup of one chatbot rendered with sleekAi_render_chatbot(), after sleekAi/chatbot/markup. The key is sleek-ai_chatbot_data_ followed by the key passed to the function, or by an MD5 hash of its data without one.

Parameter Type Description
$markup string|false The markup so far.
$chatbot array The chatbot’s settings.

Returns string|false Markup to insert into the chatbot’s frame.

sleekAi/chatbot/markup

Filter, fired in product/includes/classes/Chatbot/Chatbot.php.

Adds markup, usually <style> elements, to every chatbot widget and embedded chat. The markup is inserted into the chatbot’s frame when it renders, not into the page.

Parameter Type Description
$markup string|false The markup so far; false when there is none.
$chatbot array The chatbot’s settings.

Returns string|false Markup to insert into the chatbot’s frame.

sleekAi/chatbot/maxRequestBytes

Filter, fired in product/includes/classes/Rest/Completions.php.

The largest conversation a chatbot visitor may send in one completion request, measured as JSON. A larger request is refused with HTTP 413. Requests from administrators are not limited.

Parameter Type Description
$maxRequestBytes int The limit in bytes, 262144 (256 KiB) by default.

Returns int The limit in bytes.

sleekAi/chatbot/rateLimit

Filter, fired in product/includes/classes/Rest/Completions.php.

How many messages one visitor may send one chatbot within five minutes before further messages are refused until the window ends. Requests from administrators are not limited.

Parameter Type Description
$limit int The number of requests, 30 by default; 0 or less removes the limit.
$scope array The chatbot the request is for: its chatbotId, or the chatbotKey of one rendered with sleekAi_render_chatbot().

Returns int The number of requests.

sleekAi/chatbot/sources

Filter, fired in product/includes/classes/Chatbot/Chatbot.php.

Adds data sources for chatbot variables. The editor offers each entry as a variable source, and a chat request replaces the variable with the entry’s value. The filter runs during that REST request, so the value cannot depend on the page the visitor is on.

Parameter Type Description
$sources array Sources added so far, each an array with an id, a label and a string value.

Returns array The sources to offer.

sleekAi/chatbot/visitorContext

Filter, fired in product/includes/classes/Chatbot/Chatbot.php.

Selects a widget’s visitor context for this render only. Anonymous context carries no login nonce or user identity and can be cached.

Parameter Type Description
$context string Current user context, or anonymous.
$chatbot array The stored or inline chatbot settings.

Returns string The visitor context for this widget.

sleekAi/init

Action, fired in product/includes/classes/Plugin.php.

Fires once after Sleek AI has booted: its REST routes, WP-CLI commands, chatbots, alt text and Agent modes are registered. The suite and the standalone plugin boot it on plugins_loaded, so only a plugin, not a theme, can add a callback in time.

Parameter Type Description
$plugin \SleekAi\Plugin The booted plugin instance, also returned by sleekAi().

sleekAi/polling

Filter, fired in product/includes/classes/Assets.php.

Decides whether completions are written to a file the browser polls instead of being streamed as server-sent events. The server reads it when it answers a completion, and chatbot widgets receive it with their page data. The default is the result of the streaming test a browser last reported.

Parameter Type Description
$usePolling bool True when the last streaming test found that the server cannot stream.

Returns bool True to poll, false to stream.

sleekAi/retention/days

Filter, fired in product/includes/classes/Retention.php.

The number of days Sleek AI keeps chats. While it is above 0, the daily sleekAi/retention/prune action deletes every chat last updated longer ago, with its messages; 0 keeps every chat.

Parameter Type Description
$days int The retention.days setting, 0 unless it is set.

Returns int Days to keep chats; 0 or less keeps them all.

sleekAi/retention/prune

Action, fired in product/includes/classes/Retention.php.

Runs daily in Action Scheduler, group sleek-ai, while sleekAi/retention/days is above 0. Sleek AI’s own callback deletes stale completion files and the chats – workspace chats, Agent conversations and chatbot logs – last updated before the retention period, with their messages.

sleek_ai_chatbot_retrieval_weight

Filter, fired in product/includes/classes/Chatbot/Retrieval.php.

Filters the retrieval weight of one post in a chatbot’s index, after the post type’s and its query’s priority. Results are clamped between 0.5 and 1.5.

Parameter Type Description
$weight float The weight so far, 1.0 for normal.
$postId int The post’s ID.
$postType string The post’s type.
$chatbotId int The chatbot’s post ID.

Returns float The post’s weight.

Stay in the Loop!  

Be the first to hear about new updates, special offers, and helpful tips, delivered straight to your inbox.

We respect your inbox (and your privacy). Read our privacy policy.