# 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:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [August 28, 2023, 1:01am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/1 "2023-08-28T01:01:52Z")

</div>

> [@Discourse AI - AI bot](https://meta.discourse.org/t/discourse-ai-ai-bot/266012/1):
>
> - `ai_helper_add_ai_pm_to_header`: add robot to the top of the page to initiate messages

I think adding groups to AI chatbot setting, does not display the button when they have access to the AI bot. Trust level/admin only gets to see this button in my case.

---

<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.

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [August 30, 2023, 11:44pm UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/3 "2023-08-30T23:44:50Z")

</div>

I was trying to say that it looks like, this PM button only shows up for admins/staff, no matter the allowed groups. It seems the PM button in header setting, does not respect the allowed AI bot groups, but rather are fixed on admin only? I can’t get this to show to a normal user.

---

<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 31, 2023, 12:02am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/4 "2023-08-31T00:02:18Z")

</div>

> [@MarcP](#):
>
> this PM button only shows up for admins/staff, no matter the allowed groups.

This is certainly not the case, at least not here… just added you to bot-testers group, can you see the button here? (reload)

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [August 31, 2023, 12:20am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/5 "2023-08-31T00:20:34Z")

</div>

Hm, it seems to work here. I can’t get it to work on two instances. Strange.. I went through all settings multiple times now.

---

<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 31, 2023, 12:23am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/6 "2023-08-31T00:23:09Z")

</div>

Our current settings are:

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/1/2/412cb64d7be33d657e4b9e94e700112a19a69078.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/b/9/0/b905f71dca78846db7773f7524afe27dd6380b2d.png)

But I am about to fix this site setting name cause it is really confusing.

Are you latest?

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [August 31, 2023, 12:29am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/7 "2023-08-31T00:29:27Z")

</div>

My settings are almost completely the same, but I have a trust-level group in the list. However, also tried without admin/TL groups, and only the ai-bot group with the same result, also tried safemode with themes/non-officials turned off, no button in all cases 🤔

I am latest indeed.

---

<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 31, 2023, 12:37am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/8 "2023-08-31T00:37:10Z")

</div>

could this be an interaction with another plugin, can you rebuild with all the non official plugins removed?

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [August 31, 2023, 12:42am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/9 "2023-08-31T00:42:20Z")

</div>

Sure, I’m rebuilding rn. Let u know in a bit, this is quite a slow server 😀

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [August 31, 2023, 1:01am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/10 "2023-08-31T01:01:45Z")

</div>

No change after the rebuild. My current plugin list:

```plaintext

    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-whos-online.git
          - git clone https://github.com/discourse/discourse-data-explorer.git
          - git clone https://github.com/discourse/discourse-fingerprint.git
          - git clone https://github.com/discourse/discourse-adplugin.git
          - git clone https://github.com/discourse/discourse-chat-integration.git
          - git clone https://github.com/discourse/discourse-docs.git
          - git clone https://github.com/discourse/discourse-chat.git
          - git clone https://github.com/discourse/discourse-gamification
          - git clone https://github.com/discourse/discourse-openid-connect
          - git clone https://github.com/discourse/discourse-rss-polling
          - git clone https://github.com/discourse/discourse-ai

```

FYI, the user can message the AI. It’s just the button that doesn’t show for users.

---

<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: [September 1, 2023, 5:30am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/11 "2023-09-01T05:30:16Z")

</div>

hmm any luck? I hate to say this, but can you try bisecting the official plugins as well to see if any of them are clashing, maybe start by rebuilding with just discourse-ai? Nothing bad will happen, you can always rebuild with the rest of them shortly after.

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [September 1, 2023, 7:51pm UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/12 "2023-09-01T19:51:44Z")

</div>

I will give this a try, will let you know. I did notice, it’s not just the header button, but also the AI composer helper that has the same issue.

**UPDATE**  
I found the bug for you, it has to do with group privacy.

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/f/5/7f542b77e38893c6b87b0d63e8fb63b1b15b596e.png)

Every value below this (owners/owners+mods) will result into hiding the button. Not sure if this is documented somewhere, might have missed it.

Adding the bot to the group, did not make any difference. Changing the above shown visibility setting did.

---

<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: [September 1, 2023, 11:02pm UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/13 "2023-09-01T23:02:03Z")

</div>

Nice one, this is very resolvable, will sort out next week

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [September 2, 2023, 5:36pm UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/14 "2023-09-02T17:36:51Z")

</div>

No hurry for me. I’d like to add that the same issue is also happening with Trust Level groups, since they are hidden by default. Changing the visibility does make the AI PM button appear.

---

<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: [September 3, 2023, 11:52pm UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/15 "2023-09-03T23:52:43Z")

</div>

I have it fixed per:

[https://github.com/discourse/discourse-ai/pull/180](https://github.com/discourse/discourse-ai/pull/180)

Will be merged later today.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [September 6, 2023, 6:19am UTC](https://meta.discourse.org/t/ai-bot-icon-not-appearing-in-header-for-non-staff/277960/16 "2023-09-06T06:19:49Z")

</div>


