When it fires
Right after kimaai_chatbot_ai_payload, once the request is prepared and before it runs, in a chatbot request or a search answer. It fires for answers that stream and for those that do not, and also for a quick action whose callback answers without the provider. KimaAI’s answer sources (Pro) start their list for the request here.
The action cannot change the request; use kimaai_chatbot_ai_payload for that. Pair it with kimaai_chatbot_after_response and kimaai_chatbot_error to time or count the requests.
Parameters
| Name | Type | Description |
|---|---|---|
ai_payload | array | The request to the provider, after kimaai_chatbot_ai_payload. |
payload | array | The normalised request payload, with prompt, postId, postSection, lang, sessionId and chatbot_settings, and assistantSurface in a search answer. |
chatbot_settings | array | The chatbot settings. |
Example
add_action(
'kimaai_chatbot_before_request',
function (array $ai_payload, array $payload): void {
error_log(sprintf('KimaAI asks %s (%s)', $ai_payload['aiModel'], $payload['assistantSurface'] ?? 'chatbot'));
},
10,
2
);
Related
kimaai_chatbot_ai_payload: changes the request before this action.kimaai_chatbot_after_response: fires after the answer.kimaai_chatbot_error: fires when the provider fails.