When it fires
When the visitor rates an answer with Helpful or Not helpful under it (POST /wp-json/kimaai/v1/chatbot/feedback/message), after the rating was checked and stored. A rating is refused, and the action does not fire, when the payload is invalid, the conversation belongs to another account, the answer does not exist in that conversation or it was rated already: each answer takes one rating.
KimaAI hooks it itself for the conversation insights and the human handoff (Pro), which can send a conversation with several ratings down to the team. 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. |
message_id | string | The ID of the rated answer in the chat history. |
rating | int | 1 for helpful, -1 for not helpful. |
comment | string | For not helpful, the reason the visitor picked and their comment, joined by a colon; empty for helpful. |
Example
add_action(
'kimaai_chatbot_message_feedback_saved',
function (string $session_id, string $message_id, int $rating, string $comment): void {
if ($rating !== -1) {
return;
}
wp_remote_post(
'https://hooks.slack.com/services/T000/B000/XXXX',
[
'headers' => ['Content-Type' => 'application/json'],
'body' => wp_json_encode(['text' => 'An answer was rated not helpful: ' . ($comment !== '' ? $comment : 'no reason given')]),
]
);
},
10,
4
);
Replace the Slack address with your incoming webhook.
Related
kimaai_chatbot_csat_saved: fires for the rating of the whole conversation.kimaai_chatbot_handoff: fires when ratings sent a conversation to the team.