code-chat-br / whatsapp-api

CodeChat - WhatsApp Api
https://docs.codechat.dev
Apache License 2.0
566 stars 236 forks source link

Messages only arriving in Whatsapp Windows installation #117

Closed gutodiasdev closed 4 months ago

gutodiasdev commented 5 months ago

Hi, i'm using N8N to send a message with image and caption to a number list. But the message only arrives in Whatsapp Windows.

API version: 1.3

Anyone know how to solve the problem and show the messages in all devices?

jrCleber commented 4 months ago

The body of your request is probably incorrect. Are you passing the correct mediatype? Does the media url contain the file extension? If not, enter the fileName.

gutodiasdev commented 4 months ago

The media type was image, we do have some custom caption, they can

Here is an example, in whatsapp windows everything is perfect. Screenshot_3

But here in app: 434718190_384334631142993_6260814709005334056_n

In n8n automation the part of image input: { mediatype: "image", caption: "string", media: "...cloudfront.net/user_2eBgK1j4GtX4yWVBmpcdpQKyBZ8/1711625204317_image" }

jrCleber commented 4 months ago

Entendi!

Isso tem a ver com o mimetype do arquivo; a aplicação não está identificando corretamente se é uma imagem, ou um vídeo, ou um arquivo, etc.

Isso ocorre porque na url da mídia não contém a extensão do arquivo; se é .png, ou .webp, ou jpg, etc.

{
  mediatype: "image",
  caption: "string",
  media: "...cloudfront.net/user_2eBgK1j4GtX4yWVBmpcdpQKyBZ8/1711625204317_image"
}

No corpo da requisição informe o filename, por exemplo:

{
  mediatype: "image",
  caption: "string",
  filename: "1711625204317_image.png",
  media: "...cloudfront.net/user_2eBgK1j4GtX4yWVBmpcdpQKyBZ8/1711625204317_image"
}
gutodiasdev commented 4 months ago

Funcionou!

Não utilizei o filename, pra funcionar direitinho eu preciso instalar o sharp no pra garantir a conversão do buffer e apenas indiquei , e adicionei a extensão .jpg na criação dos links.

Muito obrigado, @jrCleber.