Closed mrbarnk closed 4 years ago
@github-actions run
@mrbarnk you can try:
var vCardsJS = require('vcards-js');
...
//create a new vCard
var vCard = vCardsJS();
//set properties
vCard.firstName = 'Eric';
vCard.middleName = 'J';
vCard.lastName = 'Nesser';
vCard.organization = 'ACME Corporation';
vCard.photo.attachFromUrl('https://avatars2.githubusercontent.com/u/5659221?v=3&s=460', 'JPEG');
vCard.workPhone = '+13125551212';
vCard.birthday = new Date(1985, 0, 1);
vCard.title = 'Software Developer';
vCard.url = 'https://github.com/enesser';
vCard.note = 'Notes on Eric';
//get as formatted string
const vcard = vCard.getFormattedString();
//make sure you add the name as the third parameter!!!
client.sendVCard('4477777777777@c.us',vcard,'Eric Nesser')
If you don't put the name at the end then it will send it as some random contact in your contact list.
Report back if working.
Thanks
I didn't have success to use, @smashah - When i tried to send, using exactly your exemple above, nothing is received on destination, infinite clock on message queue sender.. probably something with encoding of vCard or something like that,not worked for me, :(
Debug Info { WA_VERSION: '0.4.2088', PAGE_UA: 'WhatsApp/0.4.613 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36', SULLA_HOTFIX_VERSION: '1.8.39', BROWSER_VERSION: 'Chrome/80.0.3987.0' }
@github-actions run
It's not sending @smashah This is the vcard after printing it. BEGIN:VCARD 0|index | VERSION:3.0 0|index | FN;CHARSET=UTF-8: 0|index | N;CHARSET=UTF-8:;;;; 0|index | TEL;TYPE=WORK,VOICE:2341234567890 0|index | REV:2020-04-06T19:54:52.653Z 0|index | END:VCARD
Debug Info {
WA_VERSION: '0.4.2088',
PAGE_UA: 'WhatsApp/0.4.613 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, li
hrome/79.0.3945.88 Safari/537.36',
SULLA_HOTFIX_VERSION: '1.8.41',
BROWSER_VERSION: 'HeadlessChrome/80.0.3987.0'
}
Here is my code.
//set properties vCard.firstName = fname; vCard.middleName = middleName; vCard.lastName = lname; vCard.workPhone = res.contact[0];
//get as a formatted string const vcard = vCard.getFormattedString();
@mrbarnk please share the actual code used to send the vcard.
@mrbarnk you can try:
var vCardsJS = require('vcards-js'); ... //create a new vCard var vCard = vCardsJS(); //set properties vCard.firstName = 'Eric'; vCard.middleName = 'J'; vCard.lastName = 'Nesser'; vCard.organization = 'ACME Corporation'; vCard.photo.attachFromUrl('https://avatars2.githubusercontent.com/u/5659221?v=3&s=460', 'JPEG'); vCard.workPhone = '+13125551212'; vCard.birthday = new Date(1985, 0, 1); vCard.title = 'Software Developer'; vCard.url = 'https://github.com/enesser'; vCard.note = 'Notes on Eric'; //get as formatted string const vcard = vCard.getFormattedString(); //make sure you add the name as the third parameter!!! client.sendVCard('4477777777777@c.us',vcard,'Eric Nesser')
If you don't put the name at the end then it will send it as some random contact in your contact list.
Report back if working.
Thanks
I'm on phone now, but I sent it as it were from here. Does it work from your side?
@mrbarnk I've tested this again. It's working as expected
await client.sendVCard(message.from,"BEGIN:VCARD\r\nVERSION:3.0\r\nFN;CHARSET=UTF-8:Eric J Nesser\r\nN;CHARSET=UTF-8:Nesser;Eric;J;;\r\nBDAY:19850101\r\nPHOTO;TYPE=JPEG:https:\/\/avatars2.githubusercontent.com\/u\/5659221?v=3&s=460\r\nTEL;TYPE=WORK,VOICE:312-555-1212\r\nTITLE;CHARSET=UTF-8:Software Developer\r\nORG;CHARSET=UTF-8:ACME Corporation\r\nURL;CHARSET=UTF-8:https:\/\/github.com\/enesser\r\nNOTE;CHARSET=UTF-8:Notes on Eric\r\nREV:2020-04-10T15:58:21.810Z\r\nEND:VCARD",'TEST CONTACT');
If you have more problems please make an issue. This one is resolved now. Thanks
NOOOOOOOOOOOOOOOOOOO, it's not working.
APRIL FL :), you are a genius. It working after upgrading to @open-wa/wa-automate
Thanks so much.
This is how it's sending, can it be like this?
FYI, the two numbers are on whatsapp.
@mrbarnk That's a good question. After analyzing a manual vcard message there is something different in the vcard text. It has a little waid
section injected in the number.
So, using the above example
changing:
...5659221?v=3&s=460\r\nTEL;TYPE=WORK,VOICE:312-555-1212\r\nTITLE;CHARSET=UTF-8:Softwa
into
...5659221?v=3&s=460\r\nTEL;TYPE=WORK,VOICE;waid=4477777777777:312-555-1212\r\nTITLE;CHARSET=UTF-8:Softwa
results in the buttons showing up.
So ;waid=4477777777777
is injected before the :
and after TEL:TYPE=
.
Can you do me a favour and work on a regex function that injects the string into the middle?
Not unless there was a special version of it
oh!, I will use the string then.
Thanks!
@github-actions run
@mrbarnk
Try this update. It now takes an extra param: https://open-wa.github.io/wa-automate-nodejs/classes/whatsapp.html#sendvcard
Hi,
I was able to make the contact appear, as you guided. Thanks! My only question is: Is there a way to define the name on the sticker? Here for me, it is "contact".
Currently, my code is like this:
await client.sendVCard(message.from, "BEGIN:VCARD\r\nVERSION: 3.0\r\nN:LastName;FirstName;;;\r\nFN:FistName LastName\r\nORG:Business;\r\nTEL;waid=551111111111:+55 11 1111-1111\r\nEND:VCARD", 'New Contact');
Does anyone know how to proceed?
Hello @smashah, I want to be able to send VCard that will appear like the sendContact function.
Thanks :).