When it fires
Whenever KimaAI works out the retention period from the settings: before each run of the daily cleanup, and on admin and cron requests while it keeps the cleanup scheduled. The cleanup runs only while “Delete old conversations” is on; this filter cannot switch it on.
A conversation counts as old when its last message is older than the days returned. The cleanup then deletes its messages, ratings, conversation facts, topic links and tool records, and unlinks it from the conversions it led to, which stay counted. 0 or less keeps every conversation.
Parameters
| Name | Type | Description |
|---|---|---|
days | int | The days of the setting, 0 when the custom number is 0. |
chatbot_settings | array | The chatbot settings. |
mode | string | The setting’s choice, 6_months, 1_year, 2_years, 5_years or custom_days. |
Returns
int: The days to keep; 0 or less keeps every conversation.
Example
add_filter(
'kimaai_chatbot_session_retention_days',
function (int $days): int {
// Company policy: no conversation older than 90 days, whatever the setting says.
return min($days, 90);
}
);
Related
kimaai_chatbot_session_retention_should_run: pauses a cleanup run.kimaai_chatbot_session_retention_before_cleanup: fires before a run deletes anything.kimaai_chatbot_session_retention_after_cleanup: fires after a run.