kimaai_chatbot_message_feedback_saved

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

NameTypeDescription
session_idstringThe conversation’s session ID.
message_idstringThe ID of the rated answer in the chat history.
ratingint1 for helpful, -1 for not helpful.
commentstringFor 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.

  • kimaai_chatbot_csat_saved: fires for the rating of the whole conversation.
  • kimaai_chatbot_handoff: fires when ratings sent a conversation to the team.

What are your feelings