When it fires
Right after kimaai_chatbot_gate returned anything but true, in a chatbot request or a search answer, before the visitor gets the refusal with status 403. This covers KimaAI’s own banned words and banned IP addresses as well as the rules of your gate callbacks. The request ends here: no session is opened, the daily limit does not count it and nothing reaches the AI provider.
The action cannot change the outcome. $payload['prompt'] holds the blocked message with card numbers and IBANs masked; it can still contain other personal data, so think before you store it.
Parameters
| Name | Type | Description |
|---|---|---|
error_message | string | The message the visitor gets. |
payload | array | The normalised request payload, with prompt, postId, lang and chatbot_settings; postSection in the chat, assistantSurface in a search answer. |
data | array | The request’s JSON body. |
request | WP_REST_Request | The REST request. |
Example
add_action(
'kimaai_chatbot_blocked',
function (string $error_message, array $payload): void {
$surface = $payload['assistantSurface'] ?? 'chatbot';
error_log(sprintf('KimaAI blocked a message (%s): %s', $surface, $error_message));
},
10,
2
);
Related
kimaai_chatbot_gate: decides whether a message is blocked.kimaai_chatbot_rate_limited: fires when a visitor reaches the daily limit instead.