Open NiiiYaa opened 4 weeks ago
Hey @NiiiYaa ,
i think i did not understood your question yet. You have to host your own whatsapp-api instance. You then send messages to it, which itself sends the message via the whatsapp backend servers to your phone. So no, the communication is not fully local there.
For the Homeassistant integration, as the readme says, you simply adding this to your configuration.yaml: notify:
Replacing the necessarry infos. The url is the one of your whatsapp api server.
If your whatsapp api server is running on the same machine, it should not be a problem to use localhost instead.
Hello Chris,
Thank you for your prompt response!
I’ve successfully installed this locally, and it’s working well with my home automation setup. I can send messages to WhatsApp numbers via the integration, and everything is functioning as expected.
However, I have a different question: Is there a way to use this local Docker setup (which is already installed and working) to send a WhatsApp message by posting a URL? For example, I want to send an alert from a local monitoring app, like Uptime Kuma, by posting a URL (Webhook).
Currently, I’m using a third-party service where I can post a URL that sends a WhatsApp message, like this:
http://api.[service name].com/whatsapp.php?source=web&phone=[number]&apikey=[key]&text=[text text text]
Is there an equivalent method (post URL) to achieve this with the local service/Docker setup? If so, what is the correct structure?
Thank you in advance for your assistance.
No problem! :) Still not 100% sure if i understood you correctly, but yes, the whatsapp api is basically just a REST wrapper of the Whatsapp Web application. A documentation of the REST Interface can be found here
As you can see, you e.g. send a message like that: POST /client/sendMessage/{sessionId} with the corresponding body: { "chatId": "6281288888888@c.us", "contentType": "string", "content": "Hello World!" }
But there are endless possibilities.
This repo (wapi-custom-notifier) just again wraps this REST Api and makes it available to Home Assistant. So if you looking into a way of interacting with Whatsapp per REST calls, you should have a look on the underlaying library found here
By the way - unrelated this issue/question. The integration, as-is, with Home Assistance yields errors. (as It expects a media-url). In the file (code) noyify.py - I disabled lines 69-77 (moved those to be comments) and that solved this altogether.
It expects an optional media-url. Why is it an error? Like that you can attach multiple medias to your message. But if you want to further talk about that, please open a separate issue
Cannot make it work.
From HA is works fine.
But when I try to post a message via a URL I'm getting the following error: "Error: AxiosError: Request failed with status code 404 {"success":false,"error":"contentType invalid, must be string, MessageMedia, MessageMediaFromURL, Location, Buttons, List, Contact or Poll"}"
This is how it look from the local app that post the URL:
What kind of headers do you send with the POST? Since the body is a json i could imagine you are missing the JSON header? So "Content-Type: application/json".
Working fine now. Thank you very much!!!
No problem 👍🏻 :)
Hello, I hope you're doing well. I wanted to ask if there's a way to send a message via a local URL (e.g., http://localhost:3000/...). If so, could you please provide the URL structure? Thank you in advance for your help.