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

[BUG] Endpoint /label/handleLabel retorna sucesso mas não aplica a etiqueta no WhatsApp (Problema JID vs LID)

Open willzins opened this issue 7 months ago • 8 comments

Welcome!

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

What did you do?

O endpoint de aplicar etiquetas em contatos (/label/handleLabel) retorna sucesso na requisição ("add": true), porém a tag não é refletida no aplicativo do WhatsApp.

Investigando o comportamento e os logs, foi identificado que o erro ocorre devido à exigência atual do WhatsApp (arquitetura multi-device) de usar o formato LID (@lid) para manipulação de etiquetas, enquanto a Evolution API está forçando o envio em JID (@s.whatsapp.net).

Passos para reproduzir:

Fazer um POST para {{base_url}}/label/handleLabel/{{instance}}

Enviar o body:

JSON { "number": "5551999999999", "labelId": "16", "action": "add" } A API retorna 200 OK com o JID formatado:

JSON [ { "numberJid": "[email protected]", "labelId": "16", "add": true } ]

A etiqueta não é aplicada no celular. Falso positivo.

Teste adicional realizado (A Causa Raiz): Tentei forçar o envio do número já no formato LID no body da requisição (ex: "number": "114087400878253@lid" capturado via webhook de grupo). Ainda assim, a função de formatação interna da Evolution "limpa" a requisição, ignora o @lid e reescreve a saída forçando para @s.whatsapp.net. A biblioteca Baileys processa sem erro, mas o servidor do WhatsApp ignora a ação.

Sugestão de Correção:

A camada de serviço de labels (src/services/whatsapp.service.ts ou label.service.ts) precisa ser ajustada.

Antes de chamar a função do Baileys para aplicar a etiqueta, a Evolution deve consultar/resolver o JID do contato para descobrir o LID correspondente.

Passar o identificador resolvido em @lid para a função de etiquetar do Baileys. Ou, alternativamente, permitir que o endpoint aceite e não sobrescreva a string quando o usuário já enviar com a terminação @lid.

What did you expect?

.

What did you observe instead of what you expected?

.

Screenshots/Videos

.

Which version of the API are you using?

Last, Versão: 2.3.7

What is your environment?

Docker

Other environment specifications

No response

If applicable, paste the log output

No response

Additional Notes

No response

willzins avatar Apr 29 '26 15:04 willzins

Did you manage to resolve it? I'm having the same unpleasant problem with Chatwoot. It can't be that this only happened to the two of us.

olabarriaga96 avatar Apr 30 '26 17:04 olabarriaga96

Did you manage to resolve it? I'm having the same unpleasant problem with Chatwoot. It can't be that this only happened to the two of us.

In my case its not in ChatWoot. But check in other issues, a lot of people saying same thing.

willzins avatar Apr 30 '26 17:04 willzins

I'm having the same problem too.

cleidsonsantos-coder avatar May 05 '26 11:05 cleidsonsantos-coder

Problem: WhatsApp stopped reaching Chatwoot even with Evolution connected and the instance paired.

Cause: a webhook set under Settings → Integrations → Webhook was pointing to a firewall-blocked endpoint. Sidekiq went into a retry loop, exhausted its workers, and starved the
processing of new messages from Evolution.

Fix: deleted the webhook under Settings → Integrations. Sidekiq drained and messages came back.

Tip: if messages disappear and the stack looks fine, check the Chatwoot app logs before touching Evolution. Integrations webhooks are blocking — a slow or unreachable destination
kills the whole pipeline.

olabarriaga96 avatar May 05 '26 12:05 olabarriaga96

Poxa, isso é muito necessário.

TiagoGouvea avatar May 13 '26 15:05 TiagoGouvea

PR - endpoint syncLabels (não mergeado): https://github.com/EvolutionAPI/evolution-api/pull/2421

TiagoGouvea avatar May 13 '26 15:05 TiagoGouvea

I'm having the same problem too.

Gilberto-F-S-Junior avatar May 18 '26 01:05 Gilberto-F-S-Junior

Olá! Estamos fazendo uma triagem do backlog para reduzir duplicação.

Esta issue reporta o mesmo problema rastreado em #1872. Vamos consolidar as discussões lá para concentrar atenção da maintainer team e evitar fragmentação.

Por favor:

  • Acompanhe #1872 para updates
  • Adicione lá quaisquer detalhes/logs novos que não estejam no thread original
  • Se você acredita que é um problema diferente, comente em #1872 explicando a diferença e podemos reabrir

Obrigado pelo report!

DavidsonGomes avatar May 19 '26 14:05 DavidsonGomes