zai-org / zai-org/feedback

[Feature Request] chat.z.ai: Add DM User Allowlist/Restriction for Hosted Discord Bot

Open
#390 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

πŸš€ Feature Request

Add DM access control settings for the hosted Z.ai Discord bot integration, allowing bot owners to restrict which Discord users can send DMs to their bot instance.

Target Platform: chat.z.ai dashboard β†’ Discord/IM Channel Configuration

πŸ“‹ Current Behavior (Problem)

❌ Issue

The hosted Z.ai Discord bot currently accepts DMs from ANY user who shares a server with the bot. There is no dashboard setting to:

  • Restrict DM access to specific user IDs
  • Block unauthorized users from consuming bot owner's quota
  • Prevent unwanted DM interactions
🎯 Use Case

Bot owners using the hosted Z.ai integration for personal use want to prevent other server members from:

  • Consuming their paid quota via DM interactions
  • Accessing their private bot instance
  • Sending unsolicited messages

"Currently, the hosted Z.ai Discord bot accepts DMs from any user who shares a server with it. There is no dashboard setting to restrict DM access to specific Discord user IDs."
β€” kori [db], Discord


βœ… Proposed Solution

New Dashboard Setting

Add a DM Access Policy section under Discord/IM channel configuration in chat.z.ai:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Discord Bot DM Settings               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                         β”‚
β”‚  DM Access Policy:                      β”‚
β”‚  β—‹ Open (anyone can DM)        [current]β”‚
β”‚  ● Allowlist (restricted)       [NEW]   β”‚
β”‚  β—‹ Disabled (no DMs)            [NEW]   β”‚β”‚                                         β”‚β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚nβ”‚  β”‚ Allowed User IDs (one per line)β”‚     β”‚β”‚  β”‚                             β”‚        β”‚β”‚  β”‚ 123456789012345678          β”‚        β”‚β”‚  β”‚ 987654321098765432          β”‚        β”‚β”‚  β”‚                             β”‚        β”‚β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚β”‚                                         β”‚β”‚  β—‹ Silently ignore DMs from others      β”‚β”‚  β—‹ Reply with "access denied" message    β”‚β”‚                                         β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜```### Expected Behavior When Enabled
| Scenario | Behavior |
|----------|----------|
| Authorized user sends DM | βœ… Processed normally |
| Non-authorized user sends DM | πŸ”‡ Silently ignored (or custom rejection) |
| User not in allowlist attempts DM | No quota consumed, no response |

---

## πŸ”— Precedent: Self-Hosted OpenClaw

This feature **already exists** in self-hosted OpenClaw configurations:

```yaml
# openclaw.config.yaml
dmPolicy: "allowlist"
allowFrom:
  - "123456789012345678"
  - "987654321098765432"

Request: Port this same capability to the hosted Z.ai service via dashboard UI.


πŸ’‘ Implementation Suggestions

Priority: MEDIUM-HIGH
Phase 1: Basic Allowlist (MVP)
  • Add "DM Policy" dropdown: Open | Allowlist | Disabled
  • Text area for comma-separated or newline-separated Discord user IDs
  • Server-side validation of user ID format (17-19 digit snowflake)
  • Silent ignore behavior for non-authorized DMs
Phase 2: Enhanced Features
  • Import from Discord role/server membership
  • Custom rejection message option
  • DM access log (who attempted, when)
  • Rate limiting per-user even within allowlist
Phase 3: Advanced
  • Time-based allowlist (temporary access windows)
  • Webhook notification on blocked DM attempt
  • Per-user quota limits within shared bot instance

🎯 User Impact

Who Benefits?
User Type Benefit
Personal bot hosters Prevent quota theft by server members
Team/small org Control internal bot access
Premium subscribers Protect $168/month plan usage
Privacy-focused users Ensure only authorized DMs processed
Quota Protection

This is primarily a billing protection feature:

  • Unauthorized DMs consume bot owner's quota
  • No way to track/block this currently
  • Could lead to unexpected charges from bad actors

πŸ“Š Technical Considerations

Discord API Level
  • No Discord gateway changes needed
  • Filter at message receive handler before processing
  • Check message.author.id against allowlist
  • If not allowed: return early, don't increment usage
Database Schema
ALTER TABLE bot_configurations
ADD COLUMN dm_policy ENUM('open', 'allowlist', 'disabled') DEFAULT 'open',
ADD COLUMN dm_allowlist JSON; -- Array of snowflake strings
Edge Cases
Case Recommended Handling
Empty allowlist + allowlist mode Treat as "disabled" β€” block all
User leaves server but still in allowlist Still allowed (ID-based, not membership)
Bot owner removes themselves from allowlist Warning: "You'll lose DM access"
DM from bot itself/other bots Always ignore (standard practice)

πŸ”’ Security Implications

Positive
  • βœ… Prevents quota exhaustion attacks
  • βœ… Reduces unauthorized API usage surface
  • βœ… Aligns hosted feature parity with self-hosted security options
Risks
  • None significant β€” purely additive feature, opt-in

πŸ”„ Alternatives Considered

Alternative Pros Cons Verdict
Status quo No dev work Quota vulnerable, user complaints ❌ Rejected
Server-level restriction Broader control Overkill, affects channels too ⚠️ Partial
Dashboard allowlist (PROPOSED) Granular, UI-friendly, matches OpenClaw Dev work required βœ… Recommended

πŸ“ Additional Context

User Statement

"Self-hosted OpenClaw already supports this via dmPolicy: 'allowlist' + allowFrom in config, but the hosted Z.ai service has no equivalent setting. Requested: A DM access restriction setting in the Z.ai dashboard (chat.z.ai) under the Discord/IM channel configuration, allowing bot owners to specify which Discord user IDs are authorized to DM the bot. DMs from non-authorized users should be silently ignored."

"Use case: Bot owners using the hosted integration for personal use want to prevent other server members from consuming their quota or interacting with their bot instance via DM."
β€” kori [db], Discord


πŸ”— Discord Thread Reference

Original Report: Feature request submitted by kori [db] via Discord


Submitted by: Roman Galaxys10 (Roman) β€” Z.ai Volunteer Ambassador
Discord: bignavi_x
GitHub: romangalaxys10-spec
Source: Discord Community β€” User: kori [db]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up β€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the chat.z.ai dashboard’s Discord/IM channel configuration, the hosted bot’s message receive handler, and the bot_configurations schema named in the issue. Compare the hosted flow with the referenced dmPolicy/allowFrom behavior. Done means owners can configure open, allowlist, or disabled DM access, unauthorized messages are blocked before quota usage, and the setting is validated and persisted.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
backend, databases, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.