Ruben Ramos
Ruben Ramos

Reputation: 65

Is there any way to send messages through WhatsApp channels using a client API?

I'd like to know if there is a method to automatically send messages to the new WhatsApp channel feature. I've conducted some research on the subject, but I haven't found much information.

I'm open to any approach for sending automated messages, whether it's using the WhatsApp.js library, the official WhatsApp API, or a third-party library's API. Any suggestions or guidance would be greatly appreciated.

Upvotes: 2

Views: 1698

Answers (1)

Hafiz
Hafiz

Reputation: 256

I found a service that allows you to work with channels. As I understand it, they have only recently introduced it, so right now the functionality is limited only by the ability to send text to channels, but they promise that this month the whole functionality will be available (sending media, creating, connecting administrators, getting reactions, etc.). Warning, this is an independent solution from Meta, so use this with the risks in mind: https://whapi.cloud/whatsapp-channels

You will need to connect any phone number, and copy the instance token.

So, to send a message to your channel, first you need to find out the channel id via a query: https://whapi.readme.io/reference/getnewsletters

curl --request GET \
 --url https://gate.whapi.cloud/newsletters \
 --header 'accept: application/json' \
 --header 'authorization: Bearer Your_Token'

In response, you get a list of channels your number is subscribed to. Among the retrieved data will be the channel name, profile picture, the channel ID and more. As I understand it, you can't get it from the interface, only this way. Or I haven't found any other way.

After that, use the method to send a text message to the channel by its id: https://whapi.readme.io/reference/sendmessagetext

curl --request POST \
 --url https://gate.whapi.cloud/messages/text \
 --header 'accept: application/json' \
 --header 'authorization: Bearer Your_Token' \
 --header 'content-type: application/json' \
 --data '
{
"typing_time": 0,
"to": "127484603030286310@newsletter",
"body": "Hello, world!"
}
'

Upvotes: 3

Related Questions