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

[BUG] Documentation on contactMessage is wrong #1135

Open
jmedellinc opened this issue Nov 15, 2024 · 0 comments
Open

[BUG] Documentation on contactMessage is wrong #1135

jmedellinc opened this issue Nov 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jmedellinc
Copy link

The README is wrong on the contactMessage data structure.
https://github.com/WhiskeySockets/Baileys?tab=readme-ov-file#non-media-messages

Two changes needed:

  • on the vcard string, "N" should be used instead of "FN" (It also helps to exemplify that using semi-colons, one can send first name and last name for the whatsapp app to reccognize)
  • on the message data itself, displayName should be inside the vcard object inside of the array of contacts.

Here's the working code:

const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
            + 'VERSION:3.0\n' 
            + 'N:Singh;Jeff \n' // full name
            + 'ORG:Ashoka Uni;\n' // the organization of the contact
            + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
            + 'END:VCARD'
const sentMsg  = await sock.sendMessage(
    id,
    { 
        contacts: { 
            contacts: [{ displayName: 'Jeff',  vcard }] 
        }
    }
)

What fails:

  • If you follow the sample code in the readme, the card is sent to the user with a generic "Contact" display name. Also, the name is not displayed in the contact card

Thanks

@jmedellinc jmedellinc added the bug Something isn't working label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant