Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support for Channels #254

Closed
shayki5 opened this issue Jan 10, 2024 · 5 comments
Closed

[Feature Request] Support for Channels #254

shayki5 opened this issue Jan 10, 2024 · 5 comments
Labels

Comments

@shayki5
Copy link

shayki5 commented Jan 10, 2024

Hi, Whatsapp released a new feature called "Channels".
Can you add a support to send messages and media to channels?
Thank you!

@allburov allburov added the enhancement New feature or request label Jan 15, 2024
@allburov
Copy link
Contributor

Sure it'd be great! Waiting for engines to support it

@mzayn
Copy link

mzayn commented Feb 21, 2024

any update for this, sending message at channel at bailey.

@devlikepro
Copy link
Contributor

devlikepro commented Jul 8, 2024

July's priority 🤞

patron:PRO

@devlikepro
Copy link
Contributor

devlikepro commented Jul 15, 2024

The first step has been done!
https://waha.devlike.pro/docs/how-to/channels/

ℹ️ not all features are supported right now by the engines. If you see a blank space on desired feature - kindly leave +1 comment in the feature request (or create another if there's no for the feature yet)
You can find all Channels related issue by scope:Channels github label


💡 Channels have a special @newsletter prefix, so you can distinguish them from regular chats and groups.

  • 123123123@c.us

Endpoints

Get all channels

You can get list of known channels

  • Get all (your and subscribed) channels GET /api/{session}/channels
  • Filter channels GET /api/{session}/channels?role=OWNER,
    • role can be OWNER, ADMIN, SUBSCRIBER
[
  {
    "id": "111111111111111111@newsletter",
    "name": "Channel - Owner - Picture",
    "description": "Hi there, I'm new here",
    "invite": "https://whatsapp.com/channel/111111111111111111GdZ60l",
    "preview": "https://mmg.whatsapp.net/m1/v/t24/123",
    "picture": "https://mmg.whatsapp.net/m1/v/t24/123",
    "verified": false,
    "role": "OWNER"
  },
  {
    "id": "111111111111111111@newsletter",
    "name": "Channel - Subscriber - No Picture",
    "description": "",
    "invite": "https://whatsapp.com/channel/111111111111111111111111",
    "preview": null,
    "picture": null,
    "verified": false,
    "role": "SUBSCRIBER"
  }
]

Create a new channel

You can create a new channel POST /api/{session}/channels with the payload:

{
  "name": "Channel Name",
  "description": "Channel Description",
  "picture": {
    "mimetype": "image/jpeg",
    "filename": "filename.jpg",
    "url": "https://github.com/devlikeapro/waha/raw/core/examples/dev.likeapro.jpg"
  }
}

Delete a channel

You can delete a channel DELETE /api/{session}/channels/123123%40newsletter (escape @ to %40).
Make sure have OWNER role for the channel.

Get channel by ID

You can get a channel by ID GET /api/{session}/channels/123123%40newsletter (escape @ to %40).

{
  "id": "111111111111111111@newsletter",
  "name": "Channel - Owner - Picture",
  "description": "Hi there, I'm new here",
  "invite": "https://whatsapp.com/channel/111111111111111111GdZ60l",
  "preview": "https://mmg.whatsapp.net/m1/v/t24/123",
  "picture": "https://mmg.whatsapp.net/m1/v/t24/123",
  "verified": false,
  "role": "OWNER"
}

Get channel by Invite Code

You can get a channel by Invite Code GET /api/{session}/channels/{inviteCode}

  • inviteCode here is the last part in invite URL https://whatsapp.com/channel/111111111111111111GdZ60l - 111111111111111111GdZ60l

💡 To get full picture you need to get channel by ID after you get the invite code.

{
  "id": "111111111111111111@newsletter",
  "name": "Channel - Owner - Picture",
  "description": "Hi there, I'm new here",
  "invite": "https://whatsapp.com/channel/111111111111111111GdZ60l",
  "preview": "https://mmg.whatsapp.net/m1/v/t24/123",
  "picture": "https://mmg.whatsapp.net/m1/v/t24/123",
  "verified": false,
  "role": "OWNER"
}

How-to

Send Text to the channel

You can use regular [POST /api/sendText]({{< relref "/docs/how-to/send-messages#send-text" >}}) endpoint to send a text message into the channel

👉 Make sure you're OWNER or ADMIN for the channel

{
  "session": "default",
  "chatId": "12132132130@newsletter",
  "text": "Hi there!"
}

Send Image to the channel

You can use regular [POST /api/sendImage]({{< relref "/docs/how-to/send-messages#send-image" >}}) endpoint to send an image into the channel

{
  "session": "default",
  "chatId": "11111111111@newsletter",
  "file": {
    "mimetype": "image/jpeg",
    "url": "https://github.com/devlikeapro/waha/raw/core/examples/dev.likeapro.jpg",
    "filename": "filename.jpeg"
  },
  "caption": "string"
}

Get messages from the channel

You can use regular
[GET /api/{session}/chats/{chatId}/messages]({{< relref "/docs/how-to/chats#get-messages-from-chat" >}})
to fetch messages from the channel

GET /api/default/chats/123%40newsletter/messages?downloadMedia=true&limit=100
[
  {
    "id": "true_111111111111111111@newsletter_1111111111111111111111",
    "timestamp": 1720775833,
    "from": "111111111111111111@newsletter",
    "fromMe": true,
    "body": "Caption",
    "hasMedia": true,
    "media": {
      "mimetype": "image/jpeg",
      "filename": null,
      "url": "http://localhost:3000/api/files/1111111111111111111111.jpeg"
    },
    "mediaUrl": "http://localhost:3000/api/files/1111111111111111111111.jpeg",
    "ack": 0,
    "ackName": "PENDING",
    "_data": {
      ...
    }
  }
]

Receive messages from the channel

For all incoming messages in your own and subscribed channels you'll receive

  • [message]({{< relref "/docs/how-to/receive-messages#message" >}}) event for a message from the channel (send by someone else)
  • [message.any]({{< relref "/docs/how-to/receive-messages#message.any" >}}) event for a message from the channel (including your messages)
{
    "event": "message",
    "session": "default",
    "me": {
        "id": "111111111111@c.us",
        "pushName": "Slovakia WAHA"
    },
    "payload": {
        "id": "false_123123@newsletter_11111111111111111111111111111111",
        "timestamp": 1720776511,
        "from": "111111111111111111@newsletter",
        "fromMe": false,
        "body": "How are you all?! ❤️",
        "hasMedia": false,
        "ack": null,
        "ackName": "UNKNOWN",
        "_data": {
          ...
        }
    },
    "engine": "NOWEB",
    "environment": {
        "version": "2024.7.4",
        "engine": "NOWEB",
        "tier": "PLUS",
        "browser": "/usr/bin/google-chrome-stable"
    }
}

patron:PRO

@devlikepro
Copy link
Contributor

devlikepro commented Jul 15, 2024

Can you add a support to send messages and media to channels?

This one is done for both engines (WEBJS and NOWEB), so closed the issue 👍
image

Polls are not ready yet tho :(

patron:PRO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants