Skip to main content

shareContactCard()

Shares your contact card in a specific chat.

Parameters

chatGuid
string
required
The GUID of the chat where you want to share your contact card.

Returns

void
void
This method completes without returning a value.

Example

const chatGuid = 'iMessage;-;+1234567890';
await client.contact.shareContactCard(chatGuid);
console.log('Contact card shared successfully');
The contact card shared is your own contact information associated with the iMessage account.

Use cases

  • Automatically share contact information in new conversations
  • Respond to contact information requests
  • Include contact details in automated workflows

shouldShareContact()

Checks whether you should share your contact card in a specific chat based on the chat’s current state.

Parameters

chatGuid
string
required
The GUID of the chat to check contact sharing status for.

Returns

shouldShare
boolean
required
true if you should share your contact card, false otherwise.

Example

const chatGuid = 'iMessage;-;+1234567890';
const shouldShare = await client.contact.shouldShareContact(chatGuid);

if (shouldShare) {
  await client.contact.shareContactCard(chatGuid);
  console.log('Contact card shared');
} else {
  console.log('Contact card already shared or not needed');
}

Smart contact sharing workflow

// Automatically share contact card when appropriate
client.on('message:received', async (message) => {
  const { chatGuid } = message;
  
  const shouldShare = await client.contact.shouldShareContact(chatGuid);
  
  if (shouldShare) {
    await client.contact.shareContactCard(chatGuid);
    console.log(`Shared contact card in chat: ${chatGuid}`);
  }
});
Use this method before calling shareContactCard() to avoid redundant sharing attempts.

Best practices

  • Check shouldShareContact() before attempting to share to avoid unnecessary API calls
  • Contact card sharing is typically done once per conversation
  • Consider privacy implications when automatically sharing contact information

Build docs developers (and LLMs) love