evolution-api icon indicating copy to clipboard operation
evolution-api copied to clipboard

fix(chatwoot): QR code not delivered when bot conversation is resolved after init

Open cesar-carlos opened this issue 5 months ago • 1 comments

Description

When using Chatwoot bot contact (CHATWOOT_BOT_CONTACT=true), sending init in the bot conversation (+123456) can start Baileys QR generation, but the QR image/instructions never arrive in Chatwoot.

Steps to reproduce

  1. Enable Chatwoot integration with bot contact
  2. Open bot conversation in the instance inbox
  3. Send init (or let initInstanceChatwoot send it on setup)
  4. Chatwoot automation resolves the conversation (status: resolved)
  5. Baileys generates QR codes

Expected behavior

QR code image and scan instructions are posted to the bot conversation.

Actual behavior

  • Evolution logs: WARN [ChatwootService] conversation not found
  • User receives no QR in Chatwoot
  • Instance stays connecting until QRCODE_LIMIT is reached

Root cause

createBotMessage / createBotQr only target conversations with status === 'open' via getOpenConversationByContact(). If the bot thread is resolved by automations, QR delivery fails silently.

Suggested fix

Reopen the latest bot inbox conversation (or create one) before posting QR/status bot messages. Also tighten init command matching and avoid duplicate QR messages per refresh.

Pull request

#2579

Environment

  • Evolution API v2.3.7
  • Integration: WHATSAPP-BAILEYS + Chatwoot
  • Observed in production with Chatwoot automations resolving bot conversations after init

cesar-carlos avatar Jun 11 '26 15:06 cesar-carlos

we are already in 2.4.0-rc2, try it with that << than change your PR to develop

dpaes avatar Jun 12 '26 03:06 dpaes