whatsapp

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package whatsapp is the gateway's WhatsApp adapter over the Meta Cloud API. Like GitHub it receives inbound messages by webhook (a GET verification handshake plus POSTed message events) and, unlike GitHub, can reply — so it exposes Send, posting through the Graph API. It stays INERT until the Meta business is verified: the gateway only mounts it when whatsapp.active is set in gateway.yaml (see internal/gateway/config), because Meta verification is an external account state the code can't observe. The user stores the access and verify tokens in the global .env (WHATSAPP_ACCESS_TOKEN, WHATSAPP_VERIFY_TOKEN); the phone number id is a non-secret setting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	// contains filtered or unexported fields
}

Channel is a WhatsApp Cloud API connection.

func New

func New(phoneNumberID, accessToken, verifyToken, appSecret, mediaDir string) *Channel

New builds a WhatsApp channel from the phone number id and its tokens. appSecret is the Meta app secret used to verify inbound message signatures; it must be non-empty for the handler to accept POSTed messages. mediaDir is the gateway media spool inbound images/voice notes/documents are downloaded into; "" disables media handling (text messages still flow).

func (*Channel) Handler

func (c *Channel) Handler(sink channels.Sink) http.Handler

Handler returns the webhook HTTP handler: GET performs Meta's verification handshake; POST parses inbound messages and forwards them as Inbound.

func (*Channel) Name

func (c *Channel) Name() string

Name returns the adapter identifier.

func (*Channel) Send

func (c *Channel) Send(ctx context.Context, conversation string, msg channels.Outbound) error

Send posts a text reply to a conversation (the recipient's phone number), split with the shared chunker — WhatsApp rejects over-long bodies, and this was the one adapter bypassing the shared splitter. A synthesized voice rendition (VoicePath) is uploaded and sent first as an audio message, best-effort — the text always follows.

Jump to

Keyboard shortcuts

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