It looks like this is the same known issue that causes problems with templates.
everyone-group-unable-to-see-private-templates
In this case, the ai-bot options appear, but the bot simply never responds.
The discussion addresses a bug where the Discourse AI bot fails to respond when the âAI bot allowed groupsâ setting is configured to âeveryoneâ. Rusty_M identifies this as a known issue related to how the âeveryoneâ group is handled, noting that while options appear, the bot remains silent. maiki suggests that âeveryoneâ is a pseudo-group including anonymous users, who cannot access the chat bot, and recommends using trust_level_0 as an effective workaround.
RGJ confirms the bug persists and pinpoints the root cause in the playground.rb file, where the logic incorrectly returns false for anonymous users because 0 is not in their group IDs. They propose using the in_any_groups? method, which properly handles the special case for the âeveryoneâ group. Roman explains that the âeveryoneâ option was originally added to allow anonymous users to view gists, but argues that setting a Personaâs allowed groups to âeveryoneâ should not automatically make all features available to everyone.
The developers discuss removing the âeveryoneâ option from the AI bot settings entirely. sam notes that code changes might have already addressed the issue and questions if backwards compatibility code can be removed. sam and sam agree that the option should be removed to prevent this confusion. Finally, martin submits a PR (#42944) that removes the âeveryoneâ option from the settings and fixes the underlying bug identified by RGJ.
It looks like this is the same known issue that causes problems with templates.
everyone-group-unable-to-see-private-templates
In this case, the ai-bot options appear, but the bot simply never responds.
Thanks for searching for prior issues!
![]()
I think the same applies here:
You can not give anonymous users access to the chat bot, so using trust_level_0 is an effective solution for your use case. ![]()
@Roman reading through the code in Discourse I think this works now.
Is it time to close this off and remove the backwards compat code?
Itâs a bit tricky. I originally added the everyone option because we wanted to let anonymous users see gists. Every feature has its own rules so I donât think setting a Personaâs allowed groups to that will make the feature available to everyone.
This is still an issue. If âAI bot allowed groupsâ is set to everyone, the bot does not respond.
I think the bug is here
return false if (SiteSetting.ai_bot_allowed_groups_map & post.user.group_ids).blank?
If the setting is everyone then this returns false, since 0 is not in post.user.group_ids
The correct pattern is !user.in_any_groups?(SiteSetting.ai_bot_allowed_groups_map)
which has a special case for everyone:
def in_any_groups?(group_ids)
group_ids.include?(Group::AUTO_GROUPS[:everyone]) ||
(is_system_user? && (Group.auto_groups_between(:admins, :trust_level_4) & group_ids).any?) ||
(group_ids & belonging_to_group_ids).any?
end
Does it make sense to disallow âeveryoneâ to be selected for that setting? Similar to how it was done in DEV: restrict everyone on whisper groups via a new disallowed_groups attr by renato ¡ Pull Request #37515 ¡ discourse/discourse ¡ GitHub
Yeah we got to remove it⌠@martin has on his list to clean a lot of this up, but it may take a bit.
@martin should we close this one? just patch current?
Small PR here to do it, along with fixing this bug: