---
name: kimaai_chatbot_ungrounded_answer
type: action
since: 1.5.4
tier: premium
feature: knowledge-base
area: chatbot
summary: Fires when the groundedness check finds that an answer is not supported by the sources it was built from.
parameters:
  - name: message
    type: string
    description: The answer text, before the note is added.
  - name: reason
    type: string
    description: The check's short reason.
  - name: payload
    type: array
    description: The request as the provider got it, keys in snake_case, with session_id and chatbot_settings.
surfaces: [chatbot, search]
---

# kimaai_chatbot_ungrounded_answer

## When it fires

When the groundedness check (Pro) is on and an answer used sources from the knowledge base: a second model call (the utility model of the settings, else the chatbot's model) compares the answer with the retrieved snippets, and the action fires when it finds the answer goes beyond them or contradicts them. The check runs on `kimaai_chatbot_final_message` at priority 20, before the answer is saved; after the action the answer gets a note that parts of it could not be verified. Answers without sources are not checked, and a check that fails or gives no verdict does not fire it.

KimaAI hooks it itself: the conversation insights record it, and the human handoff can send the conversation to the team once the answer is saved, when its settings ask for that. The action costs the visitor time, as the answer waits for it: keep the work short.

## Example

```php
add_action(
  'kimaai_chatbot_ungrounded_answer',
  function (string $message, string $reason, array $payload): void {
    error_log(sprintf('KimaAI could not verify an answer (session %s): %s', $payload['session_id'] ?? '', $reason));
  },
  10,
  3
);
```

## Related

- `kimaai_chatbot_handoff`: fires when the conversation went to the team, also after this check.
- `kimaai_chatbot_guardrails_violation`: fires when an answer contains a banned term.
- `kimaai_chatbot_final_message`: the answer text the check reads.
