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.
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:
The setting is defined in the
settings.yml
file of the Discourse AI plugin with a default value oftrue
. This means that, by default, the button to start a PM with the AI Bot is displayed in the header.The setting is used in the
ai-bot-replies.js
file. This JavaScript file contains the logic for interacting with the AI Bot.The
attachHeaderIcon
function checks if theai_helper_add_ai_pm_to_header
setting is enabled. If it is, it retrieves the list of enabled AI Bots from theai_bot_enabled_chat_bots
setting. This setting contains a list of AI Bots that are enabled for chat, separated by a pipe (|
).If there are any enabled AI Bots, the
attachHeaderIcon
function attaches two widget actions to the header:showAiBotPanel
andhideAiBotPanel
. These actions control the visibility of the AI Bot panel.The
showAiBotPanel
action sets thebotSelectorVisible
state totrue
, which shows the AI Bot panel.The
hideAiBotPanel
action sets thebotSelectorVisible
state tofalse
, which hides the AI Bot panel.Please note that the user ID of the AI Bot is hardcoded as
-110
,-111
, and-112
in theisGPTBot
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 theai_bot_allowed_groups
setting in thesettings.yml
file of thediscourse-ai
plugin.The
ai_bot_allowed_groups
setting is used in theai-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 theentry_point.rb
module of the AI Bot. This module adds theai_enabled_chat_bots
attribute to thecurrent_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 thediscourse-ai
plugin to enforce this restriction.
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.
This is certainly not the case, at least not hereā¦ just added you to bot-testers group, can you see the button here? (reload)
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.
Our current settings are:
But I am about to fix this site setting name cause it is really confusing.
Are you latest?
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.
could this be an interaction with another plugin, can you rebuild with all the non official plugins removed?
Sure, Iām rebuilding rn. Let u know in a bit, this is quite a slow server
No change after the rebuild. My current plugin list:
- 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.
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.
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.
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.
Nice one, this is very resolvable, will sort out next week
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.
I have it fixed per:
Will be merged later today.