Skip to content

feat(whatsapp): agent tools for group create / add participants / invite link - #89033

Closed
pallaoro wants to merge 1 commit into
openclaw:mainfrom
clawnify:feat/whatsapp-group-tools
Closed

pallaoro wants to merge 1 commit into
openclaw:mainfrom
clawnify:feat/whatsapp-group-tools

Conversation

@pallaoro

@pallaoro pallaoro commented Jun 1, 2026

Copy link
Copy Markdown

What

Adds three WhatsApp agent tools so an agent can manage groups programmatically, gated behind a new channels.whatsapp.actions.groups flag (default false):

Tool Purpose
whatsapp_group_create Create a group with a subject + E.164 participants. Returns the new group JID.
whatsapp_group_add_participants Add E.164 participants to an existing group JID.
whatsapp_group_invite_link Resolve the invite code + https://chat.whatsapp.com/... link for a group the bot administers.

Why

WhatsApp already supports outbound sends (openclaw message send) and the react action, but there's no first-class way for an agent to create groups or manage membership. Baileys exposes groupCreate / groupParticipantsUpdate / groupInviteCode on the socket; this surfaces them as proper agent tools.

How

  • ActiveWebListener gains createGroup / addGroupParticipants / getGroupInviteCode, implemented in createWebSendApi over the reconnect-aware socket (same path as sendMessage/sendPoll). Phone numbers are normalized to JIDs with the existing toWhatsappJid helper.
  • createWhatsAppGroupTools({ cfg }) registers the tools via the channel's agentTools factory — they only appear when the gate is enabled, and each re-checks the gate (via live getRuntimeConfig()) and requires an active linked listener at execute time, so a disabled or unlinked install can't invoke them.
  • Security: actions.groups defaults to false because these actions can add arbitrary people to chats — opt-in, consistent with the existing reactions/polls gates.

Config

{ channels: { whatsapp: { actions: { groups: true } } } }

Tests / checks

  • Unit tests for the listener group methods (send-api.test.ts) and the agent-tool wrapper (agent-tools-groups.test.ts: gate visibility + enforcement, JID/participant validation, not-linked error).
  • tsgo:core, tsgo:extensions, tsgo:extensions:test clean.
  • Regenerated bundled-channel-config-metadata (config:channels:gen); check:bundled-channel-config-metadata passes.
  • Updated docs/channels/whatsapp.md.

…ite link

Adds three WhatsApp agent tools, gated behind a new
channels.whatsapp.actions.groups flag (default false, since they can add
arbitrary people to chats):

- whatsapp_group_create — create a group with a subject + E.164 participants,
  returns the new group JID
- whatsapp_group_add_participants — add E.164 participants to a group JID
- whatsapp_group_invite_link — resolve the invite code + chat.whatsapp.com link

The tools are registered via the channel's agentTools factory and only appear
when the gate is enabled. They operate through the existing active web
listener, so they require WhatsApp to be linked and the gateway listener to be
running — group ops are added to ActiveWebListener (createGroup /
addGroupParticipants / getGroupInviteCode) and implemented in createWebSendApi
via the reconnect-aware socket (Baileys groupCreate / groupParticipantsUpdate /
groupInviteCode). Phone numbers are normalized to JIDs with the same helper
used for outbound sends.

Includes unit tests for the listener group methods and the agent-tool wrapper
(gate visibility + enforcement, JID/participant validation, not-linked error),
the actions.groups config schema + type, regenerated channel config metadata,
and docs.
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web size: L triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 1, 2026
@clawsweeper

clawsweeper Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 6:35 PM ET / 22:35 UTC.

Summary
The PR adds default-off WhatsApp group create, add-participants, and invite-link agent tools plus listener/socket wrappers, config schema metadata, tests, and docs.

PR surface: Source +265, Tests +272, Docs +25, Generated 0. Total +562 across 14 files.

Reproducibility: not applicable. as a feature request, but the review findings are source-reproducible: the PR exposes group-admin tool calls after only the global groups gate and accepts loose participant strings.

Review metrics: 2 noteworthy metrics.

  • Action gate surface: 1 added. The new channels.whatsapp.actions.groups flag is an operator-controlled config surface for high-impact linked-account behavior.
  • Side-effecting agent tools: 3 added. The added tools can create groups, add participants, or expose invite links from the linked WhatsApp account, so reviewers need explicit security and proof coverage.

Stored data model
Persistent data-model change detected: unknown-data-model-change: src/config/bundled-channel-config-metadata.generated.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #74261
Summary: The open issue is the canonical WhatsApp group-management feature request; this PR is a concrete candidate implementation but remains blocked on security policy, proof, validation, and conflicts.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦪 silver shellfish
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add maintainer-approved sender, owner, or tool-policy authorization for all group tools.
  • [P1] Reject malformed participant entries before socket calls.
  • [P1] Post redacted live linked-WhatsApp proof for create, add-participants, and invite-link lookup, then refresh the dirty branch.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR comment provides redacted live output for group creation, but add-participants and invite-link lookup still need redacted linked-WhatsApp proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A real linked WhatsApp flow would materially help review because unit tests cannot prove transport-visible group-management behavior. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis visual task: verify a linked WhatsApp account with groups enabled can create a group, add a participant, and fetch an invite link with private details redacted.

Risk before merge

  • [P1] With the new groups gate enabled, the tools can create WhatsApp groups, add participants, and return invite links through the linked WhatsApp identity without a maintainer-approved operation-specific authorization boundary.
  • [P1] The participant parser accepts any non-empty string even though the tool schema and docs describe E.164 phone numbers.
  • [P1] The contributor's redacted live proof covers group creation only; add-participants and invite-link lookup still need redacted linked-account proof.
  • [P1] The branch is currently dirty against the base branch, so the merge result and generated metadata need a fresh refresh before landing.

Maintainer options:

  1. Require authorization, validation, proof, and refresh (recommended)
    Add maintainer-approved sender, owner, or tool-policy authorization; reject malformed participants; provide redacted live proof for create/add/invite-link; and refresh the dirty branch before merge.
  2. Accept the global gate explicitly
    Maintainers could decide that channels.whatsapp.actions.groups is the complete security boundary, but that should be explicit because these tools affect third parties through a linked identity.
  3. Pause behind the canonical feature request
    If the authorization policy is not settled, keep this PR paused while continuing design in [Feature]: whatsapp create group tool for whatsapp-agent-tools #74261 and the adjacent sender-authorization track.

Next step before merge

  • [P1] Human review is needed because the remaining blockers are security/product policy, contributor proof, and branch conflict resolution rather than a narrow automation-safe repair.

Security
Needs attention: The diff exposes linked-account WhatsApp group administration without a maintainer-approved sender, owner, or tool-policy authorization boundary.

Review findings

  • [P1] Gate group tools on sender or owner authorization — extensions/whatsapp/src/agent-tools-groups.ts:87-88
  • [P2] Reject malformed participants before socket calls — extensions/whatsapp/src/agent-tools-groups.ts:47-49
Review details

Best possible solution:

Land only after maintainers approve and enforce the WhatsApp group-administration authorization boundary, reject malformed participants, refresh the branch, and collect redacted live proof for all three operations.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a feature request, but the review findings are source-reproducible: the PR exposes group-admin tool calls after only the global groups gate and accepts loose participant strings.

Is this the best way to solve the issue?

No, not yet. The WhatsApp plugin boundary and Baileys primitives are plausible, but the best solution still needs explicit authorization policy, stricter participant validation, a clean merge result, and live linked-account proof for all three operations.

Full review comments:

  • [P1] Gate group tools on sender or owner authorization — extensions/whatsapp/src/agent-tools-groups.ts:87-88
    With actions.groups enabled, this execute path reaches linked-account group operations after only the global gate and active-listener check. Creating groups, adding participants, and returning invite links affect third parties, so this needs maintainer-approved sender, owner, or tool-policy authorization before the listener call.
    Confidence: 0.9
  • [P2] Reject malformed participants before socket calls — extensions/whatsapp/src/agent-tools-groups.ts:47-49
    The tool schema documents E.164 participants, but this parser accepts any non-empty string and later sends it through the loose WhatsApp JID normalizer. Reject malformed participant entries here so bad model input cannot become an invalid or unintended WhatsApp JID.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 843ad143647e.

Label changes

Label justifications:

  • P2: This is a bounded WhatsApp feature PR with clear user demand, but it is not a current-user outage or regression.
  • merge-risk: 🚨 security-boundary: The diff exposes WhatsApp group administration through a linked account, so authorization policy must be settled before merge.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR comment provides redacted live output for group creation, but add-participants and invite-link lookup still need redacted linked-WhatsApp proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +265, Tests +272, Docs +25, Generated 0. Total +562 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 8 266 1 +265
Tests 4 283 11 +272
Docs 1 25 0 +25
Config 0 0 0 0
Generated 1 13 13 0
Other 0 0 0 0
Total 14 587 25 +562

Security concerns:

  • [medium] Missing authorization for group administration — extensions/whatsapp/src/agent-tools-groups.ts:87
    The execute paths check the global groups flag and active listener before mutating WhatsApp groups or returning invite links. These operations can affect third parties through the linked account, so they need explicit owner, sender, or tool-policy authorization before merge.
    Confidence: 0.9

What I checked:

  • Repository policy applied: Root AGENTS.md and scoped extensions/docs AGENTS.md were read fully; plugin-boundary, config-surface, docs, dependency-contract, and security-boundary guidance apply to this PR. (AGENTS.md:28, 843ad143647e)
  • Current main lacks group tools: The WhatsApp plugin currently registers only the login agent tool, so current main has not implemented the requested group-management tool surface. (extensions/whatsapp/src/channel.ts:97, 843ad143647e)
  • Current listener lacks group operations: ActiveWebListener currently exposes send, poll, reaction, composing, and close methods, with no createGroup, addGroupParticipants, or getGroupInviteCode methods. (extensions/whatsapp/src/inbound/types.ts:32, 843ad143647e)
  • PR adds side-effecting group tools after one global gate: The PR head checks the groups action gate and active listener, then calls createGroup; the add-participants and invite-link tools follow the same listener path. (extensions/whatsapp/src/agent-tools-groups.ts:87, 71ca30a377d2)
  • Participant parser is looser than documented E.164 input: The PR trims and filters participant strings but accepts any non-empty string before sending it through the WhatsApp JID normalizer. (extensions/whatsapp/src/agent-tools-groups.ts:47, 71ca30a377d2)
  • Agent tool contract has no sender context: ChannelAgentTool is the generic AgentTool execute contract; execute receives toolCallId, params, signal, and update callback, not an inbound sender/owner context. (packages/agent-core/src/types.ts:471, 843ad143647e)

Likely related people:

  • mcaxtr: Git history shows Marcus Castro carried the account connection lifecycle refactor through the active listener and send API boundary this PR extends. (role: adjacent WhatsApp lifecycle contributor; confidence: high; commits: aa023e428306; files: extensions/whatsapp/src/inbound/send-api.ts, extensions/whatsapp/src/inbound/types.ts, extensions/whatsapp/src/connection-controller.ts)
  • steipete: Path history shows repeated plugin-boundary, channel runtime, and group-policy refactors in the surfaces that determine the correct ownership and authorization shape. (role: plugin boundary and group-policy contributor; confidence: high; commits: 2766c27b2aa6, 9cbfbd18e35e, 9ebe38b6e36b; files: extensions/whatsapp/src/channel.ts, extensions/whatsapp/src/inbound/send-api.ts, src/config/group-policy.ts)
  • vincentkoc: History includes recent WhatsApp lazy-loading, runtime seams, account config types, and release-adjacent config metadata work on the same plugin/config area. (role: recent WhatsApp runtime/config contributor; confidence: medium; commits: 2050ef2740df, e2a628b5a104, aa69b12d0086; files: extensions/whatsapp/src/channel.ts, src/config/types.whatsapp.ts, src/config/zod-schema.providers-whatsapp.ts)
  • Adam Holt: History shows Adam Holt introduced per-group tool policies, the existing sender/tool authorization surface adjacent to these new group-admin tools. (role: introduced adjacent group tool policy; confidence: medium; commits: c07949a99c12; files: src/config/group-policy.ts, src/config/types.tools.ts, extensions/whatsapp/src/channel.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-06-21T09:00:13.685Z sha 71ca30a :: needs real behavior proof before merge. :: [P1] Gate group tools on sender or owner authorization | [P2] Reject malformed participants before socket calls

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 1, 2026
@pallaoro

pallaoro commented Jun 1, 2026

Copy link
Copy Markdown
Author

Real linked-WhatsApp validation (group creation)

Per the review note asking for real behavior proof: whatsapp_group_create was validated end-to-end against a live linked WhatsApp account. The plugin was built from the v2026.5.20 tag + this PR's delta and loaded into a running gateway; the tool was invoked via a single agent turn.

tool calls:   1  (whatsapp_group_create)
failures:     0
other tools:  none
args:         { subject: "OpenClaw Tool Test", participants: ["+31•••"] }
result:       created group on the live account → JID 120363•••@g.us
final text:   Created WhatsApp group "OpenClaw Tool Test" (120363•••@g.us)

(Linked account number and participant redacted to +31•••; group JID partially redacted.)

This exercises the complete path added by the PR:

whatsapp_group_create agent tool → ActiveWebListener.createGroup → createWebSendApi → reconnect-aware socket → Baileys groupCreate, including E.164 → JID normalization.

whatsapp_group_add_participants (groupParticipantsUpdate) and whatsapp_group_invite_link (groupInviteCode) ride the same listener → socket plumbing and are covered by the unit tests, but were not separately exercised in this live run — I can add live runs for those if it helps.

pallaoro added a commit to clawnify/openclaw that referenced this pull request Jun 1, 2026
Tag-triggered (whatsapp-v*) workflow that builds the @openclaw/whatsapp fork
(group tools) and attaches the installable tarball to a GitHub Release. Fleet
installs via 'openclaw plugins install <release-url>'. Interim auto-build point
until openclaw#89033 lands.
@FelixIsaac

Copy link
Copy Markdown
Contributor

Thanks for putting this together. I hit this exact gap today on a live OpenClaw WhatsApp setup and this PR matches the missing layer.

Local notes from my install:

  • Local install: [email protected] / @openclaw/[email protected]
  • Checked latest npm release: @openclaw/[email protected]
  • Checked current main at 7bd533a8
  • In both latest release and current main, the WhatsApp active listener path still appears to expose normal outbound send/presence only, not group ops.
  • Baileys itself is not the blocker in my environment: installed [email protected] exposes groupCreate, groupParticipantsUpdate, and groupInviteCode.

The concrete failure I saw:

message(action="channel-create") -> WhatsApp action runtime -> active listener -> createGroup(...)

The OpenClaw wrapper gets to the group-create path, but the listener/send-api socket facade does not expose groupCreate, so it fails with:

Active WhatsApp socket does not support group creation.

This PR fixes the right abstraction boundary from what I can see: add group methods to the active listener/send API and put first-class agent tools behind channels.whatsapp.actions.groups.

I agree with the review concern that this should stay gated because it lets an agent create groups / add participants through the linked WhatsApp identity. For my local use, I’m applying/testing this as a local OpenClaw patch with an owner-controlled workflow rather than enabling it broadly.

The remaining things I’d most want before merge are:

  • an owner/sender authorization gate in addition to the global actions.groups flag
  • stricter participant validation/error reporting
  • redacted live proof from a linked WhatsApp account for create/add/invite-link

Happy to report back with redacted local proof if useful once I finish testing the patch.

@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jun 14, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed stale Marked as stale due to inactivity labels Jul 20, 2026
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat(whatsapp): agent tools for group create / add participants / invite link This is item 1/1 in the current shard. Shard 19/22.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict stalled_unproven_pr (decision packet 2026-07-21T20:27:06.293Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web docs Improvements or additions to documentation merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants