Skip to content

docs: update for bot API overhaul (whatsapp-rust#852) - #322

Merged
jlucaso1 merged 4 commits into
mainfrom
claude/eager-cerf-wfbdlr
Jun 11, 2026
Merged

docs: update for bot API overhaul (whatsapp-rust#852)#322
jlucaso1 merged 4 commits into
mainfrom
claude/eager-cerf-wfbdlr

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Updates the documentation to match the breaking API changes in whatsapp-rust#852.

  • quickstart.mdx — Full rewrite: single-dep Cargo.toml, use whatsapp_rust::prelude::*, typed event registrars (on_message, on_qr_code), ctx.reply("pong"), bot.run().await (single await, no ?), bot.spawn() + handle.shutdown() pattern
  • installation.mdx — Documents single-dependency consumption; sibling crates are re-exported so only whatsapp-rust + tokio are needed; UreqHttpClient path changed from transport to http
  • guides/receiving-messages.mdx — Updated event subscription section to show typed registrars as the primary pattern; updated filtering example to use on_message
  • guides/sending-messages.mdx — New "Text message shortcuts" section documenting ctx.reply, ctx.reply_quoting, client.send_text, and wa::Message::text/text_with_context
  • changelog/2026-06-11-bot-api-overhaul.mdx — New changelog entry with full breaking-change table, migration guide, and all new features

Test plan

  • Verify all Rust code blocks in quickstart.mdx compile against the new API
  • Verify installation.mdx Cargo.toml snippets reflect the new single-dep setup
  • Confirm changelog entry appears at the top of the changelog tab in the docs site
  • Check no old bot.run().await?.await? patterns remain in the edited files

https://claude.ai/code/session_012JLxpJvMsHwZymEZWpbaP7


Generated by Claude Code


Summary by cubic

Updates the docs for the bot API overhaul: simpler lifecycle, typed handlers, single-dependency setup, and new messaging helpers. Quickstart, installation, guides, and changelog reflect the breaking changes; examples compile with tokio (including signal for the ctrl+c sample).

  • New Features

    • Rewrote quickstart with use whatsapp_rust::prelude::*, typed handlers (.on_message/.on_qr_code), ctx.reply(...), and bot.run().await or spawn() + handle.shutdown(); builder defaults note that only the backend is required. The example now replies “pong” to “ping”.
    • Updated installation to single-dependency usage (whatsapp-rust + tokio), moved UreqHttpClient to whatsapp_rust::http, and added tokio to the git-revision example.
    • Refreshed guides: receiving uses typed registrars by default; sending documents ctx.reply, ctx.reply_quoting, client.send_text, and wa::Message::text/text_with_context.
    • Fixed docs: link to /api/bot instead of a broken anchor; handler examples use if let Err(e) instead of ?. Changelog entry adds a full breaking-change table and migration guidance.
  • Migration

    • Replace bot.run().await?.await? with bot.run().await, or use bot.spawn() and handle.shutdown().await for background runs.
    • Drop sibling crates from Cargo.toml; use only whatsapp-rust (re-exports wacore, wacore_binary, waproto) plus tokio.
    • Import UreqHttpClient from whatsapp_rust::http, not transport.
    • Prefer typed registrars (on_message, on_qr_code, etc.); multiple handlers now accumulate instead of replacing.
    • When following the ctrl+c example, enable tokio’s signal feature in Cargo.toml.

Written for commit d206aad. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added typed event registrars (on_message, on_qr_code, on_pair_code, on_connected, on_logged_out) for cleaner handler registration.
    • Introduced messaging convenience helpers (ctx.reply, ctx.reply_quoting, client.send_text).
    • Added Bot::spawn() for background operation with graceful shutdown controls.
  • Documentation

    • Updated all guides to reflect simplified dependency management and new API patterns.
    • Enhanced installation and quickstart guides with latest examples and best practices.

- Rewrite quickstart to use prelude::*, on_message/on_qr_code typed
  registrars, single-dep Cargo.toml, and bot.run().await (no double-await)
- Update installation to document single-dependency consumption and
  move UreqHttpClient import from transport to http module
- Update receiving-messages guide to show typed registrars as the
  primary pattern and on_message for filtering
- Update sending-messages guide to document ctx.reply/reply_quoting,
  wa::Message::text/text_with_context, and Client::send_text helpers
- Add changelog entry 2026-06-11-bot-api-overhaul with full breaking
  change table and migration guide

https://claude.ai/code/session_012JLxpJvMsHwZymEZWpbaP7
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR updates all documentation to reflect a breaking bot API overhaul, including consolidated dependencies, typed event handlers, simplified lifecycle management, and messaging convenience helpers. Installation guidance simplifies to a single dependency, quickstart examples demonstrate the new builder and handler patterns throughout, and all guides consistently use the updated API surface.

Changes

Bot API Overhaul Documentation

Layer / File(s) Summary
Breaking Changes Announcement & Installation
changelog/2026-06-11-bot-api-overhaul.mdx, docs.json, installation.mdx
New changelog entry announces all breaking API changes: re-exported core crates, UreqHttpClient relocation to prelude, Bot::run/Bot::spawn lifecycle changes, typed handler methods, and messaging helpers. Installation guide simplified to show whatsapp-rust re-exports the full stack, requiring only one dependency line in most cases.
Typed Event Handler Registration Pattern
guides/receiving-messages.mdx
Event handling guide updated to show typed registrars (on_message, on_qr_code, on_pair_code, on_connected, on_logged_out) with MessageContext delivery instead of manual event matching. Multiple handlers now accumulate, and examples demonstrate both typed handlers and catch-all patterns for untyped events.
Messaging Helpers & Text Shortcuts
guides/sending-messages.mdx
New "Text message shortcuts" section introduces convenience helpers: MessageContext reply methods (ctx.reply, ctx.reply_quoting), Client::send_text, and message constructors (wa::Message::text, wa::Message::text_with_context) that simplify plain-text and quoted replies.
Quickstart Guide & Complete Examples
quickstart.mdx
Quickstart substantially updated with prelude-based builder setup using typed handlers, message handling via on_message with MessageContext, new section on background operations and graceful shutdown (bot.spawn(), handle.shutdown()), and a complete working example demonstrating logging, CDN-reuse media replies, reactions, and quoted replies with error handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • oxidezap/whatsapp-rust-docs#250: Earlier API surface update introducing Arc<wa::Message> and MessageContext constructors that the typed handler examples and messaging helpers in this PR depend on.

Poem

🐰 A rabbit hops through code with glee,
New handlers typed, convenient, free,
One line to install, the whole stack's there,
Messages reply with API flair,
Async and spawned with graceful care!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: update for bot API overhaul (whatsapp-rust#852)' is fully related to the changeset. It accurately describes the main purpose: documentation updates reflecting the breaking API changes from whatsapp-rust#852. The title is concise, clear, and appropriately summarizes the primary change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/eager-cerf-wfbdlr

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa29e856cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread guides/sending-messages.mdx Outdated
Comment thread quickstart.mdx Outdated
- Drop broken #bothandle anchor; link to /api/bot instead (no BotHandle
  heading exists in api/bot.mdx yet)
- Replace .await? with if-let-Err in on_message examples — the handler
  closure returns () so ? would be a compile error for users copying it

https://claude.ai/code/session_012JLxpJvMsHwZymEZWpbaP7

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found and verified against the latest diff

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread changelog/2026-06-11-bot-api-overhaul.mdx
Comment thread quickstart.mdx Outdated
Comment thread installation.mdx
- quickstart: on_message handler now actually replies to "ping" with "pong"
- installation: add tokio to git-revision install example
- changelog: add tokio to migration "after" Cargo.toml snippet

https://claude.ai/code/session_012JLxpJvMsHwZymEZWpbaP7

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
changelog/2026-06-11-bot-api-overhaul.mdx (3)

6-6: 💤 Low value

Consider using second person and active voice.

The phrase "Every consumer will need a migration" uses third person. Documentation guidelines prefer second person with active voice. Consider: "You will need to migrate your code, but the migration is mechanical."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@changelog/2026-06-11-bot-api-overhaul.mdx` at line 6, Replace the
third-person passive sentence "Every consumer will need a migration" in
changelog/2026-06-11-bot-api-overhaul.mdx with a second-person, active-voice
phrasing (e.g., "You will need to migrate your code, but the migration is
mechanical.") — locate the exact sentence in the PR description paragraph and
update it to use "you" and active voice while preserving the rest of the
sentence and the note about migrations being mechanical.

Source: Coding guidelines


75-75: ⚡ Quick win

Use code formatting for method name.

The method name with_event_handler should be formatted with backticks for consistency with other code references in the documentation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@changelog/2026-06-11-bot-api-overhaul.mdx` at line 75, The documentation line
mentions with_event_handler but doesn't use code formatting; update the sentence
to wrap the method name `with_event_handler` in backticks (keeping `on_event` /
`on_event_for` already formatted) so it reads: "`on_event` / `on_event_for` are
unchanged as catch-alls. `with_event_handler` registers a struct-based
`EventHandler` directly on the bus for stateful handlers (eliminates the
clone-dance that closure captures force on consumers)." Ensure only the method
name is changed to use backticks without altering surrounding text.

Source: Coding guidelines


159-159: ⚡ Quick win

Use code formatting for filename in heading.

As per coding guidelines, file names should use code formatting. The heading references Cargo.toml which should be formatted as code: `Cargo.toml`

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@changelog/2026-06-11-bot-api-overhaul.mdx` at line 159, Heading text "Builder
dependencies — drop sibling crates from Cargo.toml" must use code formatting for
the filename; update the heading to wrap Cargo.toml in backticks (e.g., "Builder
dependencies — drop sibling crates from `Cargo.toml`") so the filename appears
as inline code in the changelog; locate the heading string in
changelog/2026-06-11-bot-api-overhaul.mdx and replace the plain filename with
the backticked version.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@changelog/2026-06-11-bot-api-overhaul.mdx`:
- Line 6: Replace the third-person passive sentence "Every consumer will need a
migration" in changelog/2026-06-11-bot-api-overhaul.mdx with a second-person,
active-voice phrasing (e.g., "You will need to migrate your code, but the
migration is mechanical.") — locate the exact sentence in the PR description
paragraph and update it to use "you" and active voice while preserving the rest
of the sentence and the note about migrations being mechanical.
- Line 75: The documentation line mentions with_event_handler but doesn't use
code formatting; update the sentence to wrap the method name
`with_event_handler` in backticks (keeping `on_event` / `on_event_for` already
formatted) so it reads: "`on_event` / `on_event_for` are unchanged as
catch-alls. `with_event_handler` registers a struct-based `EventHandler`
directly on the bus for stateful handlers (eliminates the clone-dance that
closure captures force on consumers)." Ensure only the method name is changed to
use backticks without altering surrounding text.
- Line 159: Heading text "Builder dependencies — drop sibling crates from
Cargo.toml" must use code formatting for the filename; update the heading to
wrap Cargo.toml in backticks (e.g., "Builder dependencies — drop sibling crates
from `Cargo.toml`") so the filename appears as inline code in the changelog;
locate the heading string in changelog/2026-06-11-bot-api-overhaul.mdx and
replace the plain filename with the backticked version.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 648b3c1a-a0ab-412f-8ee6-1ab15bbabdff

📥 Commits

Reviewing files that changed from the base of the PR and between 76157d7 and aa29e85.

📒 Files selected for processing (6)
  • changelog/2026-06-11-bot-api-overhaul.mdx
  • docs.json
  • guides/receiving-messages.mdx
  • guides/sending-messages.mdx
  • installation.mdx
  • quickstart.mdx

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread changelog/2026-06-11-bot-api-overhaul.mdx Outdated
- Use second-person voice ("You will need to migrate") per CodeRabbit suggestion
- Add tokio `signal` feature to migration Cargo.toml snippet so the ctrl_c example compiles

https://claude.ai/code/session_012JLxpJvMsHwZymEZWpbaP7
@jlucaso1
jlucaso1 merged commit ab41023 into main Jun 11, 2026
3 checks passed
@mintlify

mintlify Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
whatsapp-rust 🟢 Ready View Preview Jun 11, 2026, 5:44 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d206aad151

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread quickstart.mdx
```toml Cargo.toml
[dependencies]
whatsapp-rust = "0.6"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enable Tokio signal for the background example

If readers follow this Quickstart dependency block and then copy the new background-operation example below, tokio::signal::ctrl_c() will not compile because Tokio's signal module is gated behind the signal feature. Add "signal" here or avoid using tokio::signal in the page's runnable examples.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants