Skip to content

feat: support @mentions in the send message API - #321

Open
EmilioNicolas wants to merge 1 commit into
lharries:mainfrom
EmilioNicolas:feat/send-message-mentions
Open

feat: support @mentions in the send message API#321
EmilioNicolas wants to merge 1 commit into
lharries:mainfrom
EmilioNicolas:feat/send-message-mentions

Conversation

@EmilioNicolas

Copy link
Copy Markdown

What

Adds optional mentions support to the bridge's POST /api/send endpoint, so text messages can tag users with real WhatsApp mentions (blue, tappable, resolved to each recipient's contact name) instead of plain "@Number" text.

How

  • New optional field mentions: []string in SendMessageRequest (accepts phone numbers or full JIDs; numbers are normalized to <number>@s.whatsapp.net).
  • When mentions are present, the text is sent as an ExtendedTextMessage with ContextInfo.MentionedJID set (this is the metadata official clients attach for mentions). Without mentions, behaviour is unchanged (plain Conversation message).

Usage

POST /api/send
{
  "recipient": "1234567890-123456@g.us",
  "message": "Welcome @31612345678!",
  "mentions": ["31612345678"]
}

The message text should include "@" for each mentioned user; WhatsApp clients render it using each viewer's own contact list.

Notes

  • Backward compatible: mentions is optional, existing calls unchanged.
  • Tested on a live bridge (direct chats and groups): mentions render blue and tappable, with contact-name resolution on the recipient side.

@EmilioNicolas

Copy link
Copy Markdown
Author

Correction from live testing: the API field itself populates ContextInfo.MentionedJID, but clients do not replace visible @phone text with the sender contact name. Also, visible phone text paired with @lid metadata rendered as underlined phone numbers rather than named mentions. The PR description should not claim automatic contact-name substitution. I am investigating the exact payload used by official clients before recommending production use.

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

Successfully merging this pull request may close these issues.

1 participant