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

Group Mention #316

Open
Clebersonc opened this issue Jan 31, 2025 · 8 comments
Open

Group Mention #316

Clebersonc opened this issue Jan 31, 2025 · 8 comments

Comments

@Clebersonc
Copy link

How to mention someone on group?

@avoylenko
Copy link
Collaborator

Here you go:

curl -X 'POST' \
  'http://127.0.0.1:3000/client/sendMessage/test' \
  -H 'accept: */*' \
  -H 'x-api-key: your_global_api_key_here' \
  -H 'Content-Type: application/json' \
  -d '{
  "chatId": "[email protected]",
  "contentType": "string",
  "content": "Hello @mention_phone_number",
  "options": {
     "mentions": ["[email protected]"]
  }
}'

@damms005
Copy link

Hi @avoylenko I have a rather naive follow up question: in the code snipet you showed above, how is the authenticated session sent in the curl example you gave above, please?

I'll assume that WhatsApp will block unauthenticated requests, and the curl example you gave in your comment does not contains any auth/session cookie.

@avoylenko
Copy link
Collaborator

avoylenko commented Feb 10, 2025

@damms005 the session name is passed as a part of URL as param:
http://127.0.0.1:3000/client/sendMessage/**test** , in this case the session name is test

@damms005
Copy link

Thanks for the response @avoylenko

My use case is that, for a web project I'm working on, I want to automate posting of WhatsApp status.

I've read the readme multiple times but couldn't figure it out. Can you help me with details of how to achieve this, please? This is what I have done so far:

  • clone and install https://github.com/chrishubert/whatsapp-api locally
  • install dependencies and run on available port (I am using port 2020)
  • open in browser <- (I am stuck at this step). see screenshot below when I opened in browser

Image

I opened the browser console and included it in the screenshot, perhaps you may find that helpful.

What am I doing wrong, please? Or can't use this project to achieve what I described above?

@avoylenko
Copy link
Collaborator

The swagger specification should be available on http://localhost:2020/api-docs in your case.

Your next steps are:

  1. Create a new wwebjs web session:
    GET http://localhost:2020/session/start/test
  2. Get and scan the QR code when its available to auth the session:
    GET http://localhost:2020/session/qr/test/image
  3. Update the user status:
    POST http://localhost:2020/client/setStatus/test

@damms005
Copy link

damms005 commented Mar 3, 2025

Thanks so much @avoylenko I was able to make progress with the steps you gave above. However, I stopped at the update status step.

Now, coming back to really post the status, when I did http://localhost:2020/session/start/test I got response Session already exists for: test and then when I made a request to post status:

curl -X POST http://localhost:2020/client/setStatus/test

I got error response {"success":false,"error":"session_not_connected"}

How can I resolve this please?

@damms005
Copy link

damms005 commented Mar 3, 2025

I was able to use the docker option. Worked perfectly. However, I wrongly thought the client/setStatus/ endpoint is for creating a Status Update (the one that my contact scroll through etc.), but it actually is for updating profile's About string. Oopsy.

Also, checked the swagger docs included and couldn't find anything for creating the real Status Update like I described above. Am I looking at the wrong place? Or not supported. If not supported, how can I add it to the project so the feature is available for me and anyone else that may need it?

@damms005
Copy link

damms005 commented Mar 3, 2025

It's an upstream issue? @avoylenko pedroslopez/whatsapp-web.js#3373

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

No branches or pull requests

3 participants