# AI Bot icon not appearing in header for non-staff

**URL:** <https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960>\
**Category:** Bug\
**Tags:** ai, ai-bot\
**Created:** [August 28, 2023, 1:01am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960 "2023-08-28T01:01:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [August 28, 2023, 1:14am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/2 "2023-08-28T01:14:37Z")

</div>

This site setting name is misleading (cc @falco/@roman) it should be `ai_bot_add_ai_pm_to_header`

AI bot research here:

> > **Look up site setting context**
> >
> > Reading context for: ai\_helper\_add\_ai\_pm\_to\_header
> 
> The `ai_helper_add_ai_pm_to_header` is a site setting in the Discourse AI plugin. When enabled, it displays a button in the header of the Discourse forum that allows users to start a private message (PM) with an AI Bot.
> 
> Here’s a detailed breakdown of how it works:
> 
> 1. The setting is defined in the `settings.yml` file of the Discourse AI plugin with a default value of `true`. This means that, by default, the button to start a PM with the AI Bot is displayed in the header.
> 
> 2. The setting is used in the `ai-bot-replies.js` file. This JavaScript file contains the logic for interacting with the AI Bot.
> 
> 3. The `attachHeaderIcon` function checks if the `ai_helper_add_ai_pm_to_header` setting is enabled. If it is, it retrieves the list of enabled AI Bots from the `ai_bot_enabled_chat_bots` setting. This setting contains a list of AI Bots that are enabled for chat, separated by a pipe (`|`).
> 
> 4. If there are any enabled AI Bots, the `attachHeaderIcon` function attaches two widget actions to the header: `showAiBotPanel` and `hideAiBotPanel`. These actions control the visibility of the AI Bot panel.
> 
> 5. The `showAiBotPanel` action sets the `botSelectorVisible` state to `true`, which shows the AI Bot panel.
> 
> 6. The `hideAiBotPanel` action sets the `botSelectorVisible` state to `false`, which hides the AI Bot panel.
> 
> Please note that the user ID of the AI Bot is hardcoded as `-110`, `-111`, and `-112` in the `isGPTBot` function. This function checks if a user is an AI Bot based on their user ID.

* * *

> > **Look up site setting context**
> >
> > Reading context for: ai\_bot\_allowed\_groups
> 
> The `ai_bot_allowed_groups` setting controls which user groups are permitted to interact with the AI Bot in private messages. This is particularly important for controlling who can receive replies from the AI Bot in a PM context.
> 
> The default groups allowed are `@staff` (group id: 3) and `@trust_level_4` (group id: 14). These group ids are specified in the `ai_bot_allowed_groups` setting in the `settings.yml` file of the `discourse-ai` plugin.
> 
> The `ai_bot_allowed_groups` setting is used in the `ai-bot-replies.js` initializer. Here, it checks if the current user is a member of any of the allowed groups. If the user is in an allowed group and the AI Bot feature is enabled, the initializer attaches the header icon and initializes AI Bot replies.
> 
> The `ai_bot_allowed_groups` setting is also used in the `entry_point.rb` module of the AI Bot. This module adds the `ai_enabled_chat_bots` attribute to the `current_user` serializer. This attribute is included if the AI Bot feature is enabled and the authenticated user is a member of any of the allowed groups.
> 
> When a new post is created, the `post_created` event is triggered. If the post is a regular post in a private message and the post’s user is in any of the allowed groups, an AI reply job is enqueued.
> 
> In summary, the `ai_bot_allowed_groups` setting is crucial for controlling which users can interact with the AI Bot in private messages. It is used in several places in the `discourse-ai` plugin to enforce this restriction.

---

_[View the full topic](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960)._
