Skip to content

GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.

feat(webhook): include verified business info in message payloads (#866)

Alejandro048e49dfabc0
diff --git a/docs/webhook-payload.md b/docs/webhook-payload.md
index b7230a62..629c262c 100644
--- a/docs/webhook-payload.md
+++ b/docs/webhook-payload.md
@@ -209,6 +209,9 @@ Fields commonly found inside the `payload` object:
| `from_name` | string | Legacy message-event push name of the sender. It remains available for compatibility and is not replaced by `sender_display_name`. |
| `timestamp` | string | RFC3339 formatted timestamp (e.g., `2023-10-15T10:30:00Z`) |
| `is_from_me` | boolean | Whether the message was sent by the current user |
+| `is_business` | boolean | `true` when an incoming message carries the sender's verified-name certificate. Omitted otherwise. A missing field does not establish whether the sender is a business. `GET /user/info` can provide additional upstream account metadata, but does not guarantee a definitive business classification. |
+| `verified_name` | string | Business name from the upstream verified-name certificate. Present only with `is_business` and when the name is non-empty. |
+| `verified_level` | string | Raw verification level reported with the certificate, as sent by WhatsApp. GOWA does not interpret this value or guarantee that it identifies an official badge. Present only with `is_business` and when WhatsApp sends it. |
### Sender Display Name Resolution
diff --git a/src/infrastructure/whatsapp/event_message.go b/src/infrastructure/whatsapp/event_message.go
index 8d02a6f0..91b28b5b 100644
--- a/src/infrastructure/whatsapp/event_message.go
+++ b/src/infrastructure/whatsapp/event_message.go
@@ -107,6 +107,7 @@ func buildEventPayload(ctx context.Context, client *whatsmeow.Client, evt *event
if pushname := evt.Info.PushName; pushname != "" {
payload["from_name"] = pushname
}
+ buildBusinessFields(evt, payload)
// Modern WhatsApp clients (LID-migrated accounts on recent app builds) wrap
// message edits in a SecretEncryptedMessage with encType=MESSAGE_EDIT instead
@@ -285,6 +286,22 @@ func buildFromFields(ctx context.Context, client *whatsmeow.Client, evt *events.
payload["from"] = normalizedSenderJID.ToNonAD().String()
}
+// buildBusinessFields exposes optional upstream verified-name certificate fields
+// on incoming messages. Certificate absence does not establish account type,
+// and the raw verification level does not guarantee an official badge.
+func buildBusinessFields(evt *events.Message, payload map[string]any) {
+ if evt.Info.IsFromMe || evt.Info.VerifiedName == nil {
+ return
+ }
+ payload["is_business"] = true
+ if name := evt.Info.VerifiedName.Details.GetVerifiedName(); name != "" {
+ payload["verified_name"] = name
+ }
+ if level := evt.Info.VerifiedName.VerifiedLevel; level != "" {
+ payload["verified_level"] = level
+ }
+}
+
func buildMessageBody(ctx context.Context, client *whatsmeow.Client, evt *events.Message, payload map[string]any) error {
message := utils.BuildEventMessage(evt)
diff --git a/src/infrastructure/whatsapp/event_message_test.go b/src/infrastructure/whatsapp/event_message_test.go
index 81dc40c0..8381c465 100644
--- a/src/infrastructure/whatsapp/event_message_test.go
+++ b/src/infrastructure/whatsapp/event_message_test.go
@@ -10,6 +10,7 @@ import (
"go.mau.fi/whatsmeow"
"go.mau.fi/whatsmeow/proto/waCommon"
"go.mau.fi/whatsmeow/proto/waE2E"
+ "go.mau.fi/whatsmeow/proto/waVnameCert"
"go.mau.fi/whatsmeow/store"
"go.mau.fi/whatsmeow/types"
"go.mau.fi/whatsmeow/types/events"
@@ -45,6 +46,71 @@ func TestBuildEventPayloadIncludesIsFromMe(t *testing.T) {
}
}
+func TestBuildEventPayloadBusinessFields(t *testing.T) {
+ businessName := "Acme Store"
+ newEvent := func(isFromMe bool, verified *types.VerifiedName) *events.Message {
+ return &events.Message{
+ Info: types.MessageInfo{
+ MessageSource: types.MessageSource{
+ Chat: types.NewJID("123", types.DefaultUserServer),
+ Sender: types.NewJID("123", types.DefaultUserServer),
+ IsFromMe: isFromMe,
+ },
+ ID: "MSG123",
+ Timestamp: time.Date(2026, time.February, 8, 10, 0, 0, 0, time.UTC),
+ VerifiedName: verified,
+ },
+ Message: &waE2E.Message{Conversation: protoString("hello")},
+ }
+ }
+ withName := &types.VerifiedName{
+ Details: &waVnameCert.VerifiedNameCertificate_Details{VerifiedName: &businessName},
+ }
+ official := &types.VerifiedName{
+ Details: &waVnameCert.VerifiedNameCertificate_Details{VerifiedName: &businessName},
+ VerifiedLevel: "high",
+ }
+
+ tests := []struct {
+ name string
+ evt *events.Message
+ wantBusiness bool
+ wantName string
+ wantLevel string
+ }{
+ {name: "regular sender", evt: newEvent(false, nil)},
+ {name: "business sender", evt: newEvent(false, withName), wantBusiness: true, wantName: businessName},
+ {name: "business sender without details", evt: newEvent(false, &types.VerifiedName{}), wantBusiness: true},
+ {name: "officially verified business", evt: newEvent(false, official), wantBusiness: true, wantName: businessName, wantLevel: "high"},
+ {name: "own message", evt: newEvent(true, withName)},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ _, payload, err := buildEventPayload(context.Background(), nil, tt.evt)
+ assert.NoError(t, err)
+
+ isBusiness, ok := payload["is_business"]
+ assert.Equal(t, tt.wantBusiness, ok)
+ if tt.wantBusiness {
+ assert.Equal(t, true, isBusiness)
+ }
+
+ name, ok := payload["verified_name"]
+ assert.Equal(t, tt.wantName != "", ok)
+ if tt.wantName != "" {
+ assert.Equal(t, tt.wantName, name)
+ }
+
+ level, ok := payload["verified_level"]
+ assert.Equal(t, tt.wantLevel != "", ok)
+ if tt.wantLevel != "" {
+ assert.Equal(t, tt.wantLevel, level)
+ }
+ })
+ }
+}
+
func TestBuildEventPayloadIncludesPreparedPollAndStableBody(t *testing.T) {
selected := []string{"Sushi"}
hashes := []string{pollOptionHash("Sushi")}