tawn33y / whatsapp-cloud-api

A Node.js library for creating bots and sending/receiving messages using the Whatsapp Cloud API.
https://www.npmjs.com/package/whatsapp-cloud-api
GNU General Public License v3.0
189 stars 51 forks source link

Where to get name of the sender #21

Closed RyzorBent closed 2 years ago

RyzorBent commented 2 years ago

https://github.com/tawn33y/whatsapp-cloud-api/blob/dd73985e97539dd70f4eb74ee256eef63dda2062/src/startExpressServer.ts#L71

Where on the api can i get the name of the sender, When i check the from key it only has cellNumber of the sender but no name

bot.on('message', async (msg) => { console.log(msg.from.name); //undefined console.log(msg.from); //+27xxxxxxxxxx }

guskuma commented 2 years ago

Hello there. I don't think this information is available in msg payload, as per https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components

RyzorBent commented 2 years ago

Hi @guskuma,

i managed to get the name working on my local machine, can i make a pull request on this issue, o have to open a new issue for this feature?

guskuma commented 2 years ago

Hello @RyzorBent I'd say you can make a pull request. I do not own this repo but I guess any help is appreciated, right @tawn33y ?

tawn33y commented 2 years ago

@RyzorBent @guskuma Sure thing! I've reopened the issue. Feel free to open a PR on the same. Here's a guideline on the process: https://gist.github.com/tawn33y/a380c176265d5b060c5c722f1e89d79f

RyzorBent commented 2 years ago

@tawn33y i'm struggling with jest testing, in order to commit changes

perhaps you could do the change on you end? This is the code sniped to get the whatsApp user name

const name = req.body.entry[0].changes[0].value.contacts?.length ? req.body.entry[0].changes[0].value.contacts[0].profile.name : null;

guskuma commented 2 years ago

Where do you guys think this property should be? New Message property "fromName"? Or maybe set from into object with wa_id and name properties?

tawn33y commented 2 years ago

@guskuma ,I think it's best to set it under msg.from.name since the from property contains other details of the sender.

@RyzorBent, I can help you with the jest testing. Feel free to share where you are stuck. If unable, happy to take it up for you.

RyzorBent commented 2 years ago

@tawn33y, when i run npm t i get this 14 passes and 2 fails : which has to do with the verifying the token.

Screenshot 2022-08-12 at 08 01 02
RyzorBent commented 2 years ago

@tawn33y @guskuma Greetings,

Is there an impediment which is preventing this pull request to go through?

tawn33y commented 2 years ago

Hi @RyzorBent, I'm waiting for @guskuma to address some comments I left on the PR 😊

guskuma commented 2 years ago

Hey there! @tawn33y I've made changes to PR, it's ready to be reviewed. Thank you.

tawn33y commented 2 years ago

@guskuma I've tagged you on the comments you might have missed. Kindly have a look

tawn33y commented 2 years ago

Fixed by #25