Skip to content

v2.3.7 Chatwoot historical import fails for @lid conversations despite syncFullHistory=true #2478

@rferrazd

Description

@rferrazd

Welcome!

  • Yes, I have searched for similar issues on GitHub and found none.

What did you do?

We investigated this at the DB level and the problem does not appear to be configuration-related.

Environment
Evolution API: v2.3.7
Chatwoot integration enabled
syncFullHistory = true before QR scan
importContacts = true
importMessages = true
mergeBrazilContacts = true
daysLimitImportMessages = 200
What is happening
Realtime sync works for new messages, but historical chats/contacts are only partially imported into Chatwoot.

Evolution receives and stores the WhatsApp history, but most of the historical data never gets linked to Chatwoot conversations.

Evidence
Evolution vs Chatwoot counts
Evolution contacts: 710
Evolution chats: 617
Chatwoot contacts in inbox: 444
Chatwoot conversations in inbox: 445
Duplicate normalized Brazilian numbers were ruled out
This query returned no rows:

SELECT regexp_replace(split_part("remoteJid", '@', 1), '^55([0-9]{2})9?([0-9]{8})$', '55\1\2') AS normalized_phone, COUNT()
FROM "Contact"
WHERE "instanceId" = (SELECT id FROM "Instance" WHERE name = 'my_whatsapp_instance' LIMIT 1)
AND "remoteJid" LIKE '%@s.whatsapp.net'
GROUP BY 1
HAVING COUNT(
) > 1
ORDER BY COUNT(*) DESC
LIMIT 30;

To Reproduce

Steps to reproduce

  1. Start Evolution API v2.3.7 with Chatwoot integration enabled.
  2. Create a new Evolution instance.
  3. Before connecting WhatsApp, enable all of the following:
    • syncFullHistory = true
    • importContacts = true
    • importMessages = true
    • mergeBrazilContacts = true
    • daysLimitImportMessages = 200
  4. Configure the Chatwoot integration for a clean inbox.
  5. Connect a WhatsApp account that already has a large existing history, especially one where older chats/messages are stored by WhatsApp/Baileys using @lid identifiers.
  6. Wait for the initial history sync/import to complete.
  7. Confirm that realtime sync works by sending or receiving a new message after the connection.
  8. Compare the counts in Evolution and Chatwoot.

Queries used to validate

Count contacts/chats in Evolution:

SELECT COUNT(*) AS contacts
FROM "Contact"
WHERE "instanceId" = (SELECT id FROM "Instance" WHERE name = 'my_whatsapp_instance' LIMIT 1);

SELECT COUNT(*) AS chats
FROM "Chat"
WHERE "instanceId" = (SELECT id FROM "Instance" WHERE name = 'my_whatsapp_instance' LIMIT 1);

### Expected behavior

_No response_

### Environment

app.chatwoot.com

### Cloud Provider

None

### Platform

None

### Operating system

_No response_

### Browser and version

_No response_

### Docker (if applicable)

_No response_

### Additional context

_No response_

### What did you expect?

We expected all contacts and messages from whatsapp to appear in chatwoot.

### What did you observe instead of what you expected?

not all contacts and messages appeared in chatwoot.

### Screenshots/Videos

_No response_

### Which version of the API are you using?

v2.3.7

### What is your environment?

Windows

### Other environment specifications

_No response_

### If applicable, paste the log output

_No response_

### Additional Notes

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions