PHP hooks
SleekAI fires a few actions and filters for your own code. The
hooks reference lists each with its arguments and
return value; this page says which to use for what. Register them from a
plugin; a theme can use every hook here except sleekAi/init, which fires
before themes load.
SleekAI has no filter that changes a chatbot’s instruction, model or widget
settings before it renders. To build a chatbot from data that differs per
page, render it from PHP with
sleekAi_render_chatbot().
By purpose
| To | Use | Explained in |
|---|---|---|
| Run code once SleekAI has booted | sleekAi/init |
Developer API |
| Force polling or streaming | sleekAi/polling |
Streaming |
| Set how long chats are kept | sleekAi/retention/days |
Chat |
| Add chatbot display conditions | sleekAi/chatbot/conditions |
Conditions |
| Add chatbot data sources | sleekAi/chatbot/sources |
Data |
| Add styles to chatbots | sleekAi/chatbot/markup, sleekAi/chatbot/key={key}/markup, sleekAi/chatbot/id={id}/markup |
Styling |
| Change the size limit of visitors’ requests | sleekAi/chatbot/maxRequestBytes |
Model |
Scheduled actions
SleekAI runs some work in the background. You can add your own callbacks to these actions, for example to log when they run; SleekAI’s own callbacks use the default priority, 10.
| Action | When it runs |
|---|---|
sleekAi/altText/generate |
Action Scheduler, group sleek-ai, once for every image uploaded while automatic alt text is on. Receives the attachment ID. |
sleekAi/retention/prune |
Action Scheduler, group sleek-ai, daily while chats have a retention period. |
sleek_ai_chatbot_file_sync |
Action Scheduler, group sleek-ai-chatbot-sync, for each chatbot query variable with file synchronization on, at its interval. Receives the chatbot ID and the variable’s index. |
sleek_ai_chatbot_vector_store_upgrade |
Action Scheduler, group sleek-ai-chatbot-sync, five minutes after an update, until every chatbot with synchronized files has its OpenAI file store; it stops trying after twelve failed runs. |
sleek_ai_cleanup_completions |
WordPress cron, hourly. Deletes polling files older than ten minutes. |
add_action('sleekAi/altText/generate', function ($attachmentId) {
error_log('SleekAI described attachment ' . $attachmentId);
}, 20);
Priority 20 runs the callback after SleekAI has written the text.
Hooks of the workspace
The workspace assistant, the global settings panel and the shared AI service belong to the workspace, and so do their hooks, such as the one that replaces the assistant’s completions provider. They are documented with the workspace, not here.