buttons

package module
v0.0.0-...-f82c022 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

hypermeow-buttons

Native-flow buttons for HyperMeow bots — quick replies, link buttons, in-app webview, copy/call buttons, dropdown menus and location requests.

Only button types that actually work are included. Everything here was live-tested on a real phone (October 2026): sending, rendering and tap callbacks.

go get github.com/meowguck-art/hypermeow-buttons

Quick start

import buttons "github.com/meowguck-art/hypermeow-buttons"

// Send a message with buttons
_, err := buttons.Send(ctx, client, chatJID,
    "Pick one:", "footer text",
    buttons.QuickReply("Option A", "a"),
    buttons.QuickReply("Option B", "b"),
    buttons.SingleSelect("More options", []buttons.Section{{
        Title: "More options",
        Rows:  []buttons.Row{{ID: "c", Title: "Option C", Description: "desc"}},
    }}),
    buttons.CTAWebview("Open site", "https://example.com"),
    buttons.CTACopy("Copy code", "ABC123"),
)

// Read taps back in your message handler
if tap, ok := buttons.ParseTap(evt.Message); ok {
    fmt.Println("tapped:", tap.Name, "id:", tap.ID, "raw:", tap.ParamsJSON)
}

A runnable bot using all of it lives in example/.

API

Function What it does
QuickReply(displayText, id) Reply button; tapping sends the id back
CTAURL(displayText, url) Opens the link in the external browser
CTAWebview(displayText, url) Opens the link in WhatsApp's in-app browser, full screen
CTACopy(displayText, copyCode) Copies to clipboard (no callback)
CTACall(displayText, phoneNumber) Dials the number
SingleSelect(title, sections) Dropdown list in a button; pass several to build multi-menu panels
Send(ctx, client, to, body, footer, btns...) Builds and sends a button message
Message(body, footer, btns...) Builds the raw message without sending
SendLocationRequest(ctx, client, to, body, footer) Asks the user to share their location
ParseTap(msg) / TapID(msg) Extracts button name + selected id from an incoming tap

What works (live-tested)

  • ✅ quick_reply — taps return the button id
  • ✅ cta_url — external browser
  • ✅ cta_url webview — in-app browser (merchant_url + webview_presentation: "full")
  • ✅ cta_copy, cta_call
  • ✅ single_select dropdowns, including several menus in one message (settings-panel style, where each row id is a bot command)
  • ✅ send_location requests — the shared location returns as a normal location message
  • ✅ All of the above mixed in a single message

Two details that make or break it, both handled for you:

  • The trailing empty button. Message/Send append a nameless button, which makes HyperMeow tag the biz node "mixed" and avoids a 405 error on some accounts when button types are mixed.
  • Location requests are the exception. A send_location message must carry empty button params and no trailing empty button, or the client ignores it. SendLocationRequest does exactly that.

Not included — they don't work

Classic ListMessage, legacy ButtonsMessage and hydrated template buttons were tested too: the WhatsApp server accepts them, but current clients render nothing. This was verified with the library builder, with raw protobuf, with injected biz nodes (the server rejects a second biz node, error 479), and with a locally patched library matching Baileys' wire format byte for byte at the stanza level. Until that changes, use SingleSelect instead of classic lists.

Note: native-flow dropdowns render on Android; like all native-flow lists they may not render on iOS.

License

MIT

Documentation

Overview

Package buttons sends WhatsApp native-flow buttons with HyperMeow.

Only button types that were LIVE-TESTED on a real phone (2026-10-21) are included: quick_reply, cta_url, cta_url as an in-app webview, cta_copy, cta_call, single_select dropdowns (including multi-menu panels), and send_location requests.

Deliberately NOT included, because current WhatsApp clients do not render them (the server accepts them, the phone shows nothing): classic ListMessage, legacy ButtonsMessage, hydrated template buttons. Use SingleSelect instead of a classic list.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocationRequestMessage

func LocationRequestMessage(body, footer string) *waE2E.Message

LocationRequestMessage builds a send_location request message. Two details make or break it: the button params must be EMPTY, and the message must NOT carry the trailing empty button — that button would rename the biz node to "mixed", while a real location request keeps the name "send_location". The shared location returns as a normal location message.

func Message

func Message(body, footer string, btns ...*Button) *waE2E.Message

Message builds an interactive native-flow message. A nameless trailing button is appended automatically: it makes HyperMeow tag the biz node "mixed", which avoids a 405 error on some accounts when a message mixes button types.

func Send

func Send(ctx context.Context, client *whatsmeow.Client, to types.JID, body, footer string, btns ...*Button) (whatsmeow.SendResponse, error)

Send builds and sends a native-flow button message.

func SendLocationRequest

func SendLocationRequest(ctx context.Context, client *whatsmeow.Client, to types.JID, body, footer string) (whatsmeow.SendResponse, error)

SendLocationRequest builds and sends a send_location request message.

func TapID

func TapID(m *waE2E.Message) string

TapID is a convenience wrapper: just the selected id, or "".

Types

type Button

Button is a single native-flow button.

func CTACall

func CTACall(displayText, phoneNumber string) *Button

CTACall dials phoneNumber (international format, e.g. "+972501234567") when tapped.

func CTACopy

func CTACopy(displayText, copyCode string) *Button

CTACopy copies copyCode to the clipboard when tapped. It produces no callback — the bot never learns that it was tapped.

func CTAURL

func CTAURL(displayText, url string) *Button

CTAURL opens a link in the external browser when tapped.

func CTAWebview

func CTAWebview(displayText, url string) *Button

CTAWebview opens a link inside WhatsApp's in-app browser (full screen, behind a "Securely browse this business website" interstitial). It is a cta_url button carrying merchant_url + webview hints.

func QuickReply

func QuickReply(displayText, id string) *Button

QuickReply is a simple tappable reply button. Tapping it sends a native-flow response carrying the given id (see ParseTap).

func SingleSelect

func SingleSelect(title string, sections []Section) *Button

SingleSelect is a dropdown list inside a button. Tapping a row sends a native-flow response carrying the row id (see ParseTap). Pass several SingleSelect buttons to Send to build a settings-panel style message with multiple menus. Renders on Android; like all native-flow lists it may not render on iOS.

type Row

type Row struct {
	ID          string
	Title       string
	Description string
}

Row is one selectable row in a SingleSelect dropdown.

type Section

type Section struct {
	Title string
	Rows  []Row
}

Section groups rows under a title in a SingleSelect dropdown.

type Tap

type Tap struct {
	Name       string
	ParamsJSON string
	ID         string
}

Tap is a parsed native-flow button tap: the button name that was tapped (e.g. "quick_reply", "single_select"), the raw paramsJSON the client sent back, and the selected id extracted from it when present.

func ParseTap

func ParseTap(m *waE2E.Message) (Tap, bool)

ParseTap extracts a native-flow tap from an incoming message. The second return value is false when the message is not a native-flow response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址