Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Group Chat

Duragent provides layered access control for DMs and groups, with mention gating, message queuing, and per-sender policies.

Access Policies

DM Policies

Control who can send direct messages to your agent:

PolicyBehaviorUse Case
openAccept all DMs (default)Public bot
disabledReject all DMsGroup-only bot
allowlistOnly listed user IDsPrivate bot
spec:
  access:
    dm:
      policy: allowlist
      allowlist: ["12345", "67890"]

Allowlists support trailing * wildcards (e.g., user_*).

Group Policies

Control which groups the agent participates in:

PolicyBehaviorUse Case
openParticipate in any group (default)Public bot
disabledIgnore all group messagesDM-only bot
allowlistOnly listed groupsControlled deployment
spec:
  access:
    groups:
      policy: allowlist
      allowlist: ["telegram:-100123456", "discord:987654321"]

Group allowlists use {channel}:{chat_id} composite format. Wildcards are supported (e.g., telegram:* for all Telegram groups).

Mention Gating

In groups, agents use mention gating by default — they only respond when triggered.

ModeBehavior
mention (default)Only respond when @mentioned or replied to
alwaysRespond to every allowed message
spec:
  access:
    groups:
      activation: mention

Mention detection supports:

  • Explicit @bot_username in message text
  • Reply to bot’s previous message

Per-Sender Policies

Within groups, you can assign different dispositions to different senders:

DispositionLLM Sees It?Triggers Response?Use Case
allowYesYesNormal interaction
passiveYes (future turns)NoContext without triggering
silentNoNoAudit trail only
blockNoNoSpam, bad actors
spec:
  access:
    groups:
      sender_default: silent
      sender_overrides:
        "67890": allow
        "99999": block
        "admin_*": allow    # Wildcard support

Resolution order: exact sender ID match, then wildcard pattern match, then sender_default.

Context Buffer

When not mentioned in mention mode, messages from allow senders are buffered. When the agent is triggered, recent context is injected so it understands the conversation.

spec:
  access:
    groups:
      context_buffer:
        mode: silent          # silent (default) | passive
        max_messages: 100     # Max buffered messages
        max_age_hours: 24     # Max age for buffer messages
ModeStorageSurvives Crash?Token Cost
silentIn-memory bufferNoLow (only on trigger)
passiveConversation historyYesAccumulates over time

Message Queue

When messages arrive while the agent is processing, the queue handles them:

spec:
  access:
    groups:
      queue:
        mode: batch           # batch (default) | sequential | drop
        max_pending: 10
        overflow: drop_old    # drop_old | drop_new | reject
        debounce:
          enabled: true
          window_ms: 1500

Queue Modes

ModeBehaviorUse Case
batchCombine all pending into one requestRapid message senders
sequentialProcess one at a time until emptyPreserve individual context
dropDiscard pending messagesSimple, predictable

Overflow Strategies

StrategyBehavior
drop_oldEvict oldest message to make room
drop_newSilently discard the new message
rejectDiscard and send reject_message back

Debouncing

Per-sender debouncing batches rapid messages before they enter the queue (e.g., user sends 3 messages in 2 seconds — they get combined into one). The first message from an idle sender bypasses debouncing for zero latency.

Full Example

spec:
  access:
    dm:
      policy: allowlist
      allowlist: ["12345"]
    groups:
      policy: allowlist
      allowlist: ["telegram:-100123456"]
      sender_default: passive
      sender_overrides:
        "67890": allow
        "99999": block
      activation: mention
      context_buffer:
        mode: silent
        max_messages: 50
        max_age_hours: 12
      queue:
        mode: sequential
        max_pending: 5
        overflow: reject
        reject_message: "I'm busy, please wait."

Cost Impact

With mention gating, 1000 group messages/day at a 5% mention rate results in only ~50 LLM calls — a 95% reduction compared to responding to every message.