---
name: kimaai_chatbot_daily_message_limit
type: filter
since: 1.5.4
tier: free
feature: chatbot
area: chatbot
summary: Changes how many messages a visitor may send the chatbot a day.
parameters:
  - name: max_messages
    type: int
    description: The daily limit of the chatbot settings.
  - name: payload
    type: array
    description: The normalised request payload, with prompt, postId, postSection, lang, sessionId and chatbot_settings, and assistantSurface in a search answer.
  - name: user_ip
    type: string
    description: The visitor's IP address, as KimaAI resolves it (see kimaai_trusted_proxies).
returns:
  type: int
  description: The limit for this request; KimaAI makes it an integer of at least 0.
surfaces: [chatbot, search]
---

# kimaai_chatbot_daily_message_limit

## When it fires

In every chatbot request and every search answer that is not served from the cache, after the gate and before the message length is checked. KimaAI counts the answered messages per IP address and day: the request goes on while today's count is below the limit, and counts once its answer is saved. At the limit the visitor gets an error with status 400 and `kimaai_chatbot_rate_limited` fires.

The filter changes the limit for this request only, not the stored setting: return a higher number for some visitors, or 0 to let nobody through. A value that is not a whole number is cast, and anything below 0 counts as 0. KimaAI's evaluation runner (`wp kimaai eval`), `wp kimaai chat` and the MCP tool that asks the chatbot lift the limit for their own requests through this filter.

## Example

```php
add_filter(
  'kimaai_chatbot_daily_message_limit',
  function (int $max_messages, array $payload, string $user_ip): int {
    // Customers who are logged in get more messages a day.
    return is_user_logged_in() ? max($max_messages, 100) : $max_messages;
  },
  10,
  3
);
```

## Related

- `kimaai_chatbot_rate_limited`: fires when a visitor reaches the limit.
- `kimaai_trusted_proxies`: the proxies whose forwarded address counts as the visitor's.
