Baileys
Baileys copied to clipboard
How do I send a message to a whatsapp channel?
Describe the bug
I tried to send a message in channel with baileys, but it didn't work and instead sent to an id with nowhere to go.
To Reproduce Steps to reproduce the behavior:
-
I tried to find the channel id by logging into whatsapp web using kiwi browser so that I can see the Inspect element, and I found the id
120363190224821113@newsletter
as per the screenshot below -
I created a trigger function where if I send the command
!msgtochannel
can send to the channel -
After that I tried to send a command so that the message was sent to the channel, but the result was nothing at all, no error occurred.
I don't know where this is actually going.
Expected behavior I wish I could send messages to my whatsapp channel with baileys like on whatsapp web too.
Environment (please complete the following information):
- Is this on a server? No, I'm running it on my phone (termux)
- What do your
connectOptions
look like?{ auth: state, logger: P({ level: "silent" }), printQRInTerminal: false, syncFullHistory: false, generateHighQualityLinkPreview: true, version: [2,2323,4], browser: ["Chrome (Linux)", "browser", ""], }
- Do you have multiple clients on the same IP? No
- Are you using a proxy? No
a little addition, after i adding a console to see the sent message, it looks like sending a normal message but with the 120363190224821113@newsletter
id
a little addition, after i adding a console to see the sent message, it looks like sending a normal message but with the
120363190224821113@newsletter
id
what is the name of the event you use?
a little addition, after i adding a console to see the sent message, it looks like sending a normal message but with the
120363190224821113@newsletter
idwhat is the name of the event you use?
messages.upsert
but actually no message was sent on the event, then i try to add .then(console.log)
to see the structure of the message being sent
a little addition, after i adding a console to see the sent message, it looks like sending a normal message but with the
120363190224821113@newsletter
id
the JID replace 'newsletter' with 's.whatsapp.net' in JID normalization function. Channel messages are not end-to-end encrypted, so we cannot send messages to channels using the 'sendMessage' function.
a little addition, after i adding a console to see the sent message, it looks like sending a normal message but with the
120363190224821113@newsletter
idthe JID replace 'newsletter' with 's.whatsapp.net' in JID normalization function. Channel messages are not end-to-end encrypted, so we cannot send messages to channels using the 'sendMessage' function.
So, is there a workaround to send messages to the channel? or, maybe there is another solution to send a message to the channel, i'll wait for the latest update if there is one.
@Auties00 any updates on this?
Find the channel id in console by running the bot
Find the channel id in console by running the bot
I didn't find the channel id at all, how?, in the bot console it's not there either
still have update for this ? cause want to send message at channel
Do anybody get any workaround on this? Thanks in Advance.
I did lots of tests and research about this feature and seems like it's not really possible to send messages to channels through baileys right now. I couldn't find any workaround.
I've seem messages from @PurpShell on the lib discord server saying they are working on supporting WhatsApp channels.
U can send it using sock.query
I've tried it by converting function from Whatsmeow library to Baileys library
![]()
U can send it using sock.query
can your share the sample code for send message for that ?
![]()
U can send it using sock.query
Can you share the code
a little addition, after i adding a console to see the sent message, it looks like sending a normal message but with the
120363190224821113@newsletter
idthe JID replace 'newsletter' with 's.whatsapp.net' in JID normalization function. Channel messages are not end-to-end encrypted, so we cannot send messages to channels using the 'sendMessage' function.
What function could we use for Newsletter
![]()
U can send it using sock.query
Does this Work for post in status too? And which code?
![]()
U can send it using sock.query
Can you give me the short code?
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys')
const msg = { conversation: 'some text' }
const jid = '123@newsletter'
const plaintext = proto.Message.encode(msg).finish()
const plaintextNode = {
tag: 'plaintext',
attrs: {},
content: plaintext
}
const node = {
tag: 'message',
attrs: { to: jid, type: 'text' },
content: [plaintextNode]
}
return sock.query(node)
Does this Work for post in status too? And which code?
U can use sendMessage function for post status
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.
It's not an error it's log maybe your in your bot connection have log
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.
I have no idea about that. But, was the message successfully sent to the channel?
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.I have no idea about that. But, was the message successfully sent to the channel?
@Rippanteq7 No, it isn't sent to the channel :(
@Riders004 the only log i get ater trying to send the message is this:
{
tag: 'ack',
attrs: {
from: '120363261578705116@newsletter',
class: 'message',
id: '60438.34089-10',
error: '400',
t: '1713201479'
},
content: undefined
}
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.I have no idea about that. But, was the message successfully sent to the channel?
@Rippanteq7 No, it isn't sent to the channel :(
@Riders004 the only log i get ater trying to send the message is this:
{ tag: 'ack', attrs: { from: '120363261578705116@newsletter', class: 'message', id: '60438.34089-10', error: '400', t: '1713201479' }, content: undefined }
What version of baileys r u using? working fine for me using the latest version from npm
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.I have no idea about that. But, was the message successfully sent to the channel?
@Rippanteq7 No, it isn't sent to the channel :( @Riders004 the only log i get ater trying to send the message is this:
{ tag: 'ack', attrs: { from: '120363261578705116@newsletter', class: 'message', id: '60438.34089-10', error: '400', t: '1713201479' }, content: undefined }
What version of baileys r u using? working fine for me using the latest version from npm
I'm using 6.6.0. Still trying to find out what is wrong.
I don't get any error, just the "received error in ack" log and the message isn't sent. I've tried adding a timeout to the socket.query
method, but then i get a timeout error after the mentioned log.
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.I have no idea about that. But, was the message successfully sent to the channel?
@Rippanteq7 No, it isn't sent to the channel :(
@Riders004 the only log i get ater trying to send the message is this:
{ tag: 'ack', attrs: { from: '120363261578705116@newsletter', class: 'message', id: '60438.34089-10', error: '400', t: '1713201479' }, content: undefined }
i also experience this, but when i move to whatsapp which is registered as beta sometimes it can be sent even though it often still errors with error 400, I don't know what the solution is.
@Rippanteq7 how does your script work properly, or is this an error from the whatsapp server?
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.I have no idea about that. But, was the message successfully sent to the channel?
@Rippanteq7 No, it isn't sent to the channel :( @Riders004 the only log i get ater trying to send the message is this:
{ tag: 'ack', attrs: { from: '120363261578705116@newsletter', class: 'message', id: '60438.34089-10', error: '400', t: '1713201479' }, content: undefined }
i also experience this, but when i move to whatsapp which is registered as beta sometimes it can be sent even though it often still errors with error 400, I don't know what the solution is.
@Rippanteq7 how does your script work properly, or is this an error from the whatsapp server?
Well, I have no idea. My friend tried it also works fine on him
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.I have no idea about that. But, was the message successfully sent to the channel?
@Rippanteq7 No, it isn't sent to the channel :( @Riders004 the only log i get ater trying to send the message is this:
{ tag: 'ack', attrs: { from: '120363261578705116@newsletter', class: 'message', id: '60438.34089-10', error: '400', t: '1713201479' }, content: undefined }
i also experience this, but when i move to whatsapp which is registered as beta sometimes it can be sent even though it often still errors with error 400, I don't know what the solution is.
@Rippanteq7 how does your script work properly, or is this an error from the whatsapp server?
Well, I have no idea. My friend tried it also works fine on him
May I know what version of balieys and client you are?, also the same with WhatsApp what version?, is it participating in the beta program?
My version use:
- WhatsApp : 2.24.9.16 (Beta)
- Client : 2.2403.2
- Balieys Package : 6.6.0
can your share the sample code for send message for that ?
Sorry for the late reply, here's an example code for sending a text message to a channel
const { proto } = require('@whiskeysockets/baileys') const msg = { conversation: 'some text' } const jid = '123@newsletter' const plaintext = proto.Message.encode(msg).finish() const plaintextNode = { tag: 'plaintext', attrs: {}, content: plaintext } const node = { tag: 'message', attrs: { to: jid, type: 'text' }, content: [plaintextNode] } return sock.query(node)
I get this error when trying to send message with your solution. Any idea of what I could be missing?
{"level":40,"time":1713197012478,"pid":32697,"hostname":"pop-os","attrs":{"from":"120363261578705116@newsletter","class":"message","id":"16992.57232-7","error":"400","t":"1713197012"},"msg":"received error in ack"}
I already checked that the user is a channel admin and that the channel id is corret.I have no idea about that. But, was the message successfully sent to the channel?
@Rippanteq7 No, it isn't sent to the channel :( @Riders004 the only log i get ater trying to send the message is this:
{ tag: 'ack', attrs: { from: '120363261578705116@newsletter', class: 'message', id: '60438.34089-10', error: '400', t: '1713201479' }, content: undefined }
i also experience this, but when i move to whatsapp which is registered as beta sometimes it can be sent even though it often still errors with error 400, I don't know what the solution is. @Rippanteq7 how does your script work properly, or is this an error from the whatsapp server?
Well, I have no idea. My friend tried it also works fine on him
May I know what version of balieys and client you are?, also the same with WhatsApp what version?, is it participating in the beta program?
My version use:
- WhatsApp : 2.24.9.16 (Beta)
- Client : 2.2403.2
- Balieys Package : 6.6.0
- WhatsApp : 2.24.7.6 (Beta)
- Client : 2.2403.2
- Baileys Package : 6.6.0