When it fires
When the visitor sends the rating at the end of a chat (POST /wp-json/kimaai/v1/chatbot/feedback/csat), after it was checked and stored. The widget asks for it when the visitor closes the chat or starts a new conversation after at least three answers, if the satisfaction survey is on. A rating is refused, and the action does not fire, when it is not 1 to 5, the conversation belongs to another account, has no messages or was rated already: each conversation takes one rating.
KimaAI hooks it itself for the conversation insights. The comment is the visitor’s own text and can contain personal data.
Parameters
| Name | Type | Description |
|---|---|---|
session_id | string | The conversation’s session ID. |
rating | int | 1 to 5 stars. |
comment | string | The visitor’s comment, or empty. |
Example
add_action(
'kimaai_chatbot_csat_saved',
function (string $session_id, int $rating, string $comment): void {
if ($rating > 2) {
return;
}
wp_mail(
get_option('admin_email'),
sprintf('A chat was rated %d of 5', $rating),
$comment !== '' ? $comment : 'No comment.'
);
},
10,
3
);
Related
kimaai_chatbot_message_feedback_saved: fires for the rating of a single answer.