Skip to content

fix(channels): allow whatsapp native mode with use_native flag#2934

Open
dtapps wants to merge 2 commits into
sipeed:mainfrom
dtapps:fix/whatsapp-native-config-detection
Open

fix(channels): allow whatsapp native mode with use_native flag#2934
dtapps wants to merge 2 commits into
sipeed:mainfrom
dtapps:fix/whatsapp-native-config-detection

Conversation

@dtapps
Copy link
Copy Markdown
Contributor

@dtapps dtapps commented May 24, 2026

📝 Description

Fix WhatsApp channel configuration detection to support native mode with use_native: true.

Currently, when type: "whatsapp" is set, the channel is only considered configured if bridge_url is not empty. This prevents the native mode (whatsmeow) from working when users set use_native: true and leave bridge_url blank, as documented.

The fix changes the validation logic to accept either:

  • bridge_url != "" (Bridge mode)
  • use_native == true (Native mode)

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

📚 Technical Context (Skip for Docs)

🧪 Test Environment

  • Hardware: PC
  • OS: Linux
  • Model/Provider: N/A
  • Channels: WhatsApp

📸 Evidence (Optional)

Click to view Logs/Screenshots

Before fix:


(WhatsApp channel not started despite being enabled with use_native: true)

After fix:
WhatsApp channel starts correctly when use_native: true is set without bridge_url.

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly. (No doc update needed - aligns code with existing docs)

dtapps added 2 commits May 24, 2026 10:47
When type is 'whatsapp' and use_native is true, the channel should be
considered configured even if bridge_url is empty. This aligns with the
documentation which states users can set use_native: true and leave
bridge_url blank for native mode.

Fixes the issue where whatsapp channel with use_native: true was not
starting because the configuration check only looked for bridge_url.
When type is 'whatsapp' and use_native is true, dynamically switch to
using the 'whatsapp_native' factory instead of the bridge factory.

This allows users to configure:
  type: 'whatsapp'
  use_native: true

And have it automatically use the native whatsmeow implementation,
without needing to change the type to 'whatsapp_native'.

This aligns the behavior with the existing documentation.
@afjcjsbx
Copy link
Copy Markdown
Collaborator

The "effective channel type" is only corrected in pkg/channels/manager.go, but the rest of the manager continues to use the type configured in pkg/channels/events.go and pkg/channels/manager.go.

With type: "whatsapp" and use_native: true, initChannel() correctly initializes the whatsapp_native factory. However, the channel.lifecycle.started/start_failed/stopped events and any other type-based logic outside of initChannel() still see whatsapp.

In practice, this PR introduces an inconsistent state: initialized says whatsapp_native, while the rest of the lifecycle says whatsapp.

I would centralize the resolution of the effective type into a shared helper and reuse it for factory lookup, runtime events, and worker creation.

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