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] (Web) Get labels and get contacts by label id #318

Closed
zulfio opened this issue May 6, 2024 · 7 comments
Closed

[Feature Request] (Web) Get labels and get contacts by label id #318

zulfio opened this issue May 6, 2024 · 7 comments

Comments

@zulfio
Copy link

zulfio commented May 6, 2024

Engine: whatsapp-web.js
Additional information: https://docs.wwebjs.dev/Client.html#getLabels

Is your feature request related to a problem?
I need this feature to retrieve available labels and get contacts within those labels.

A clear and concise description of what the problem is.
We can use this method to get labels. https://docs.wwebjs.dev/Client.html#getLabels
And this method to get contacts by label id. https://docs.wwebjs.dev/Client.html#getChatsByLabelId

A clear and concise description of what you want to happen.
NEW ENDPOINT:
Get Labels:
method: GET
URL: /labels

Get Contacts by Label ID:
method: GET
URL: /label/:label_id

@allburov allburov added enhancement New feature or request engine:WEBJS labels May 6, 2024
@Boffice
Copy link

Boffice commented May 19, 2024

+1 Will be perfect if you could add label directly to incoming message JSON.

Knowing the labels from incoming message JSON would help separate personal messages from business ones. It would also allow us to better organize customer messages based on their labels.

Also, it gives ability to create diverse workflows with automations.

patron:PLUS

@Himanshu1234556
Copy link

Himanshu1234556 commented Jun 24, 2024

I also need it.

patron:PLUS

@Himanshu1234556
Copy link

Himanshu1234556 commented Jul 17, 2024

+1

patron:PLUS

@devlikepro
Copy link
Contributor

devlikepro commented Jul 18, 2024

@devlikepro
Copy link
Contributor

devlikepro commented Jul 26, 2024

working on it, will be in 2024.8.1 version!

patron:PRO

@zulfio
Copy link
Author

zulfio commented Aug 4, 2024

Yaaay it's here 2024.8.1

patron:PRO

@zulfio zulfio closed this as completed Aug 4, 2024
@devlikepro
Copy link
Contributor

devlikepro commented Aug 4, 2024

You can work with WhatsApp Labels available in WhatsApp Business using the API!

Features

Here's the list of features that are available by 🏭 Engines:

WEBJS NOWEB
Get list of labels
GET /api/{session}/labels
✔️ ✔️
Get chats by label id
GET /api/{session}/labels/{labelId}/chats
✔️ ✔️
Get labels by chat id
GET /api/{session}/labels/chats/{chatId}/
✔️ ✔️
PUT labels to chat
PUT /api/{session}/labels/chats/{chatId}/
✔️ ✔️
labels.upsert ✔️
labels.deleted ✔️
labels.chat.added ✔️
labels.chat.deleted ✔️

If you see the feature is not available in the above list, please create a feature request or leave "+1" comment on the existing one.


Endpoints

Get list of labels

You can get a list of labels for the session using the endpoint:

GET /api/{session}/labels

Response:

[
  {
    "id": "1",
    "name": "New Client",
    "color": 1,
    "colorHex": "#64c4ff"
  },
  ...
]

Get chats by label id

You can get a list of chats by label id using the endpoint:

GET /api/{session}/labels/{labelId}/chats

ℹ️ Response right now depends on
🏭 Engine
you're using,
the same way as
💬 Chats

Get labels by chat id

You can get a list of labels by chat id using the endpoint:

GET /api/{session}/labels/chats/{chatId}/

Response:

[
  {
    "id": "1",
    "name": "New Client",
    "color": 1,
    "colorHex": "#64c4ff"
  },
  ...
]

Update labels to chat

PUT /api/{session}/labels/chats/{chatId}/

Upsert label:

👉 You need to provide the full list of labels you want to set to the chat. All other labels will be removed.

{
  "labels": [
    {
      "id": "1"
    }
  ]
}

Remove labels:

{
  "labels": []
}

Webhooks

labels.upsert

{
  "event": "label.upsert",
  "session": "default",
  "payload": {
    "id": "10",
    "name": "Label Name",
    "color": 14,
    "colorHex": "#00a0f2"
  },
  "engine": "NOWEB",
  ...
}

labels.deleted

{
  "event": "label.deleted",
  "session": "default",
  "payload": {
    "id": "10",
    "name": "",
    "color": 14,
    "colorHex": "#00a0f2"
  },
  "engine": "NOWEB",
  ...
}

labels.chat.added

{
  "event": "label.chat.added",
  "session": "default",
  "payload": {
    "labelId": "6",
    "chatId": "11111111111@c.us",
    "label": null <=== right after scanning QR it can be null. 
  },
  "engine": "NOWEB",
  ...
}

labels.chat.deleted

{
  "event": "label.chat.deleted",
  "session": "default",
  "payload": {
    "labelId": "6",
    "chatId": "11111111111@c.us",
    "label": null
  },
  "engine": "NOWEB",
  ...
}

patron:PRO

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

No branches or pull requests

5 participants