GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
feat: add ghost mentions feature for group messages
Aldino Kemale8ef5a24f6bb
diff --git a/docs/openapi.yaml b/docs/openapi.yamlindex 0e470a77..6d4014b8 100644--- a/docs/openapi.yaml+++ b/docs/openapi.yaml@@ -1,7 +1,7 @@openapi: "3.0.0"info:title: WhatsApp API MultiDevice- version: 8.1.0+ version: 8.2.0description: |This API is used for sending whatsapp via API.@@ -838,6 +838,14 @@ paths:type: integerexample: 3600description: Disappearing message duration in seconds (optional)+ mentions:+ type: array+ items:+ type: string+ example: ["628123456789", "@everyone"]+ description: |+ List of phone numbers to mention (ghost mentions - no @ required in message text).+ Use special keyword "@everyone" to mention all group participants.responses:'200':description: OKdiff --git a/readme.md b/readme.mdindex b01a047b..51737579 100644--- a/readme.md+++ b/readme.md@@ -67,6 +67,10 @@ Download:- Mention someone- `@phoneNumber`- example: `Hello @628974812XXXX, @628974812XXXX`+- **Ghost Mentions (Mention All)** - Mention group participants without showing `@phone` in message text+ - Pass phone numbers in `mentions` field to mention users without visible `@` in message+ - Use special keyword `@everyone` to automatically mention ALL group participants+ - UI checkbox available in Send Message modal for groups- Post Whatsapp Status- **Send Stickers** - Automatically converts images to WebP sticker format- Supports JPG, JPEG, PNG, WebP, and GIF formatsdiff --git a/src/domains/send/text.go b/src/domains/send/text.goindex 7cfd8b2a..9846bea4 100644--- a/src/domains/send/text.go+++ b/src/domains/send/text.go@@ -2,6 +2,7 @@ package sendtype MessageRequest struct {BaseRequest- Message string `json:"message" form:"message"`- ReplyMessageID *string `json:"reply_message_id" form:"reply_message_id"`+ Message string `json:"message" form:"message"`+ ReplyMessageID *string `json:"reply_message_id" form:"reply_message_id"`+ Mentions []string `json:"mentions,omitempty" form:"mentions"` // List of phone numbers/JIDs to mention (ghost mentions)}diff --git a/src/pkg/utils/general.go b/src/pkg/utils/general.goindex 9c7f3311..2eabce42 100644--- a/src/pkg/utils/general.go+++ b/src/pkg/utils/general.go@@ -472,3 +472,16 @@ func FormatBusinessHourTime(timeValue any) string {return fmt.Sprintf("%02d:%02d", hours, minutes)}++// UniqueStrings removes duplicate strings from a slice while preserving order+func UniqueStrings(input []string) []string {+ seen := make(map[string]bool)+ result := []string{}+ for _, s := range input {+ if !seen[s] {+ seen[s] = true+ result = append(result, s)+ }+ }+ return result+}diff --git a/src/usecase/send.go b/src/usecase/send.goindex 84fcc9b5..83ad2275 100644--- a/src/usecase/send.go+++ b/src/usecase/send.go@@ -117,7 +117,17 @@ func (service serviceSend) SendText(ctx context.Context, request domainSend.Messmsg.ExtendedTextMessage.ContextInfo.Expiration = proto.Uint32(service.getDefaultEphemeralExpiration(request.BaseRequest.Phone))}+ // Get mentions from text (existing behavior - parses @phone from message text)parsedMentions := service.getMentionFromText(ctx, request.Message)++ // Add explicit mentions from request.Mentions (ghost mentions - no @ required in text)+ if len(request.Mentions) > 0 {+ explicitMentions := service.getMentionsFromList(ctx, request.Mentions, dataWaRecipient)+ parsedMentions = append(parsedMentions, explicitMentions...)+ // Deduplicate to avoid mentioning the same person twice+ parsedMentions = utils.UniqueStrings(parsedMentions)+ }+if len(parsedMentions) > 0 {msg.ExtendedTextMessage.ContextInfo.MentionedJID = parsedMentions}@@ -989,6 +999,36 @@ func (service serviceSend) getMentionFromText(ctx context.Context, messages strireturn result}+// getMentionsFromList converts a list of phone numbers to JIDs for ghost mentions+// Special keyword "@everyone" will fetch all group participants+func (service serviceSend) getMentionsFromList(ctx context.Context, mentions []string, recipientJID types.JID) (result []string) {+ client := whatsapp.ClientFromContext(ctx)+ if client == nil {+ return result+ }++ for _, mention := range mentions {+ // Handle @everyone keyword - fetch all group participants+ if mention == "@everyone" {+ if recipientJID.Server == types.GroupServer {+ groupInfo, err := client.GetGroupInfo(ctx, recipientJID)+ if err == nil && groupInfo != nil {+ for _, participant := range groupInfo.Participants {+ result = append(result, participant.JID.String())+ }+ }+ }+ continue+ }++ // Regular phone number mention+ if dataWaRecipient, err := utils.ValidateJidWithLogin(client, mention); err == nil {+ result = append(result, dataWaRecipient.String())+ }+ }+ return result+}+func (service serviceSend) SendSticker(ctx context.Context, request domainSend.StickerRequest) (response domainSend.GenericResponse, err error) {// Validate requesterr = validations.ValidateSendSticker(ctx, request)diff --git a/src/validations/send_validation.go b/src/validations/send_validation.goindex 2db6fc1c..d8ce3c18 100644--- a/src/validations/send_validation.go+++ b/src/validations/send_validation.go@@ -76,6 +76,18 @@ func ValidateSendMessage(ctx context.Context, request domainSend.MessageRequest)if err := validateDuration(request.Duration); err != nil {return err}++ // Validate mentions if provided+ for _, mention := range request.Mentions {+ // Skip validation for special @everyone keyword+ if mention == "@everyone" {+ continue+ }+ if err := validatePhoneNumber(mention); err != nil {+ return pkgError.ValidationError(fmt.Sprintf("mention %s: phone number must be in international format", mention))+ }+ }+return nil}diff --git a/src/views/components/SendMessage.js b/src/views/components/SendMessage.jsindex 586d2fa4..7e9aeb77 100644--- a/src/views/components/SendMessage.js+++ b/src/views/components/SendMessage.js@@ -12,6 +12,7 @@ export default {text: '',reply_message_id: '',is_forwarded: false,+ mention_everyone: false,duration: 0,loading: false,}@@ -32,6 +33,9 @@ export default {isShowReplyId() {return this.type !== window.TYPESTATUS;},+ isGroup() {+ return this.type === window.TYPEGROUP;+ },isValidForm() {// Validate phone number is not empty except for status typeconst isPhoneValid = this.type === window.TYPESTATUS || this.phone.trim().length > 0;@@ -70,6 +74,11 @@ export default {payload.duration = this.duration;}+ // Add mentions if mention_everyone is checked (only for groups)+ if (this.mention_everyone && this.type === window.TYPEGROUP) {+ payload.mentions = ["@everyone"];+ }+const response = await window.http.post('/send/message', payload);this.handleReset();return response.data.message;@@ -87,6 +96,7 @@ export default {this.text = '';this.reply_message_id = '';this.is_forwarded = false;+ this.mention_everyone = false;this.duration = 0;},},@@ -128,6 +138,13 @@ export default {<label>Mark message as forwarded</label></div></div>+ <div class="field" v-if="isGroup()">+ <label>Mention Everyone</label>+ <div class="ui toggle checkbox">+ <input type="checkbox" aria-label="mention everyone" v-model="mention_everyone">+ <label>Mention all group participants (@everyone)</label>+ </div>+ </div><div class="field"><label>Disappearing Duration (seconds)</label><input v-model.number="duration" type="number" min="0" placeholder="0 (no expiry)" aria-label="duration"/>