Documentation
¶
Overview ¶
Package hypersender is the official Go client for the Hypersender WhatsApp API, SMS API, and OTP API.
client := hypersender.NewClient() // reads HYPERSENDER_* environment variables res, err := client.WhatsApp.SendText(ctx, "201234567890@c.us", "Hello from Go!", nil)
Every method takes a context, sends one request, and returns the API's JSON response as a Result (or []Result for list endpoints). Failed requests return an *Error with the HTTP status code and the API's message.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/hypersender/hypersender-go"
)
func main() {
// Reads HYPERSENDER_WHATSAPP_API_KEY and HYPERSENDER_WHATSAPP_INSTANCE_ID.
client := hypersender.NewClient()
res, err := client.WhatsApp.SendText(context.Background(), "201234567890@c.us", "Hello from Go!", nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(res["queued_request_uuid"])
}
Output:
Index ¶
- Constants
- func Bool(v bool) *bool
- type Client
- type ContactCard
- type ContactsService
- func (c *ContactsService) CheckContactExists(ctx context.Context, phone string) (Result, error)
- func (c *ContactsService) GetAllContacts(ctx context.Context, opts *GetAllContactsOptions) (Result, error)
- func (c *ContactsService) GetAllKnownLIDs(ctx context.Context, opts *GetAllKnownLIDsOptions) ([]Result, error)
- func (c *ContactsService) GetContact(ctx context.Context, chatID string) (Result, error)
- func (c *ContactsService) GetLIDByPhoneNumber(ctx context.Context, phoneNumber string) (Result, error)
- func (c *ContactsService) GetLIDsCount(ctx context.Context) (Result, error)
- func (c *ContactsService) GetPhoneNumberByLID(ctx context.Context, lid string) (Result, error)
- func (c *ContactsService) GetProfilePicture(ctx context.Context, chatID string) (Result, error)
- func (c *ContactsService) UpsertContact(ctx context.Context, chatID, firstName string, opts *UpsertContactOptions) (Result, error)
- type CreateInstanceOptions
- type EnterpriseService
- func (e *EnterpriseService) CreateInstance(ctx context.Context, phone, name string, opts *CreateInstanceOptions) (Result, error)
- func (e *EnterpriseService) GetInstanceHealth(ctx context.Context, instanceID string) (Result, error)
- func (e *EnterpriseService) ListInstances(ctx context.Context, opts *ListInstancesOptions) ([]Result, error)
- func (e *EnterpriseService) RequestNewQRCode(ctx context.Context, instanceID string) (Result, error)
- func (e *EnterpriseService) RestartInstance(ctx context.Context, instanceID string) (Result, error)
- type Error
- type GenerateLinkOptions
- type GetAllContactsOptions
- type GetAllKnownLIDsOptions
- type LinkPreview
- type ListInstancesOptions
- type ListOptions
- type Media
- type MediaOptions
- type OTPLinkCallback
- type OTPLinkMessage
- type OTPService
- func (o *OTPService) GenerateLink(ctx context.Context, chatID string, opts *GenerateLinkOptions) (Result, error)
- func (o *OTPService) RequestCode(ctx context.Context, chatID string, opts *RequestCodeOptions) (Result, error)
- func (o *OTPService) ValidateCode(ctx context.Context, chatID, code string) (Result, error)
- type Option
- type ReadChatOptions
- type RequestCodeOptions
- type Result
- type SMSService
- func (s *SMSService) DeleteMessage(ctx context.Context, messageID string) (Result, error)
- func (s *SMSService) DeleteMessageThread(ctx context.Context, messageThreadID string) (Result, error)
- func (s *SMSService) EditMessageThread(ctx context.Context, messageThreadID string, isArchived bool) (Result, error)
- func (s *SMSService) GetHeartbeats(ctx context.Context, opts *ListOptions) (Result, error)
- func (s *SMSService) ListMessageThreads(ctx context.Context, opts *ListOptions) (Result, error)
- func (s *SMSService) ListMessages(ctx context.Context, opts *ListOptions) (Result, error)
- func (s *SMSService) SendMessage(ctx context.Context, to, content string, opts *SendSMSOptions) (Result, error)
- type SendLinkCustomPreviewOptions
- type SendLocationOptions
- type SendPollOptions
- type SendSMSOptions
- type SendSeenOptions
- type SendTextOptions
- type UpsertContactOptions
- type VoiceOptions
- type WhatsAppService
- func (w *WhatsAppService) DeleteMessage(ctx context.Context, chatID, messageID string) (Result, error)
- func (w *WhatsAppService) ForwardMessage(ctx context.Context, chatID, messageID string) (Result, error)
- func (w *WhatsAppService) GetQueuedRequest(ctx context.Context, uuid string) (Result, error)
- func (w *WhatsAppService) ReactToMessage(ctx context.Context, chatID, messageID, reaction string) (Result, error)
- func (w *WhatsAppService) ReadChat(ctx context.Context, chatID string, opts *ReadChatOptions) (Result, error)
- func (w *WhatsAppService) SendContactCard(ctx context.Context, chatID string, contacts []ContactCard) (Result, error)
- func (w *WhatsAppService) SendFile(ctx context.Context, chatID string, file Media, opts *MediaOptions) (Result, error)
- func (w *WhatsAppService) SendImage(ctx context.Context, chatID string, image Media, opts *MediaOptions) (Result, error)
- func (w *WhatsAppService) SendLinkCustomPreview(ctx context.Context, chatID, text string, preview LinkPreview, ...) (Result, error)
- func (w *WhatsAppService) SendLocation(ctx context.Context, chatID string, latitude, longitude float64, ...) (Result, error)
- func (w *WhatsAppService) SendPoll(ctx context.Context, chatID, name string, options []string, ...) (Result, error)
- func (w *WhatsAppService) SendSeen(ctx context.Context, chatID, messageID string, opts *SendSeenOptions) (Result, error)
- func (w *WhatsAppService) SendText(ctx context.Context, chatID, text string, opts *SendTextOptions) (Result, error)
- func (w *WhatsAppService) SendTextSafe(ctx context.Context, chatID, text string, opts *SendTextOptions) (Result, error)
- func (w *WhatsAppService) SendVideo(ctx context.Context, chatID string, video Media, opts *MediaOptions) (Result, error)
- func (w *WhatsAppService) SendVoice(ctx context.Context, chatID string, voice Media, opts *VoiceOptions) (Result, error)
- func (w *WhatsAppService) StarMessage(ctx context.Context, chatID, messageID string, star bool) (Result, error)
- func (w *WhatsAppService) StartTyping(ctx context.Context, chatID string) (Result, error)
- func (w *WhatsAppService) StopTyping(ctx context.Context, chatID string) (Result, error)
Examples ¶
Constants ¶
const DefaultBaseURL = "https://app.hypersender.com/api"
DefaultBaseURL is the Hypersender API base URL.
const Version = "1.0.0"
Version is the SDK version, sent in the User-Agent header.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
WhatsApp *WhatsAppService
SMS *SMSService
OTP *OTPService
Enterprise *EnterpriseService
}
Client is a Hypersender API client. Create one with NewClient and reuse it; it is safe for concurrent use.
func NewClient ¶
NewClient returns a client configured from the environment and the given options. Options override environment variables.
Example ¶
package main
import (
"github.com/hypersender/hypersender-go"
)
func main() {
client := hypersender.NewClient(
hypersender.WithWhatsApp("your-api-key", "your-instance-id"),
hypersender.WithSMS("your-sms-api-key", "your-sms-instance-id"),
)
_ = client
}
Output:
type ContactCard ¶
type ContactCard struct {
FullName string `json:"fullName,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
Organization string `json:"organization,omitempty"`
WhatsAppID string `json:"whatsappId,omitempty"`
VCard string `json:"vcard,omitempty"` // a raw vCard instead of the fields above
}
ContactCard is a contact to share with SendContactCard.
type ContactsService ¶
type ContactsService struct {
// contains filtered or unexported fields
}
ContactsService looks up and saves WhatsApp contacts. Use it as client.WhatsApp.Contacts.
func (*ContactsService) CheckContactExists ¶
CheckContactExists checks if a phone number has WhatsApp. phone has the country code, without + or spaces, e.g. "201234567890". The result has numberExists and chatId.
Example ¶
package main
import (
"context"
"log"
"github.com/hypersender/hypersender-go"
)
func main() {
client := hypersender.NewClient()
ctx := context.Background()
res, err := client.WhatsApp.Contacts.CheckContactExists(ctx, "201234567890")
if err != nil {
log.Fatal(err)
}
if res["numberExists"] == true {
client.WhatsApp.SendText(ctx, res["chatId"].(string), "Welcome!", nil)
}
}
Output:
func (*ContactsService) GetAllContacts ¶
func (c *ContactsService) GetAllContacts(ctx context.Context, opts *GetAllContactsOptions) (Result, error)
GetAllContacts lists the instance's contacts.
func (*ContactsService) GetAllKnownLIDs ¶
func (c *ContactsService) GetAllKnownLIDs(ctx context.Context, opts *GetAllKnownLIDsOptions) ([]Result, error)
GetAllKnownLIDs lists the LID to phone number mappings the instance knows.
func (*ContactsService) GetContact ¶
GetContact returns a contact by phone number or chat ID ("123@c.us" or "123@lid").
func (*ContactsService) GetLIDByPhoneNumber ¶
func (c *ContactsService) GetLIDByPhoneNumber(ctx context.Context, phoneNumber string) (Result, error)
GetLIDByPhoneNumber finds the LID linked to a phone number ("3333333@c.us" or "3333333").
func (*ContactsService) GetLIDsCount ¶
func (c *ContactsService) GetLIDsCount(ctx context.Context) (Result, error)
GetLIDsCount returns how many LID mappings the instance knows.
func (*ContactsService) GetPhoneNumberByLID ¶
GetPhoneNumberByLID resolves a LID ("1111111@lid") to its phone number chat ID.
func (*ContactsService) GetProfilePicture ¶
GetProfilePicture returns the URL of a contact's WhatsApp profile picture.
func (*ContactsService) UpsertContact ¶
func (c *ContactsService) UpsertContact(ctx context.Context, chatID, firstName string, opts *UpsertContactOptions) (Result, error)
UpsertContact creates a contact, or updates its name if it already exists.
type CreateInstanceOptions ¶
type CreateInstanceOptions struct {
WebhookURL string `json:"webhook_url,omitempty"` // an https URL
}
CreateInstanceOptions are the optional fields for CreateInstance.
type EnterpriseService ¶
type EnterpriseService struct {
// contains filtered or unexported fields
}
EnterpriseService manages WhatsApp instances on an Enterprise account. Use it as client.Enterprise. The instance ID is passed on each call instead of being set on the client.
func (*EnterpriseService) CreateInstance ¶
func (e *EnterpriseService) CreateInstance(ctx context.Context, phone, name string, opts *CreateInstanceOptions) (Result, error)
CreateInstance creates a WhatsApp instance. phone is E.164 ("+201234567890"). The result has the instance id and a qr_code to scan with the phone.
func (*EnterpriseService) GetInstanceHealth ¶
func (e *EnterpriseService) GetInstanceHealth(ctx context.Context, instanceID string) (Result, error)
GetInstanceHealth checks whether an instance is connected and working.
func (*EnterpriseService) ListInstances ¶
func (e *EnterpriseService) ListInstances(ctx context.Context, opts *ListInstancesOptions) ([]Result, error)
ListInstances lists your WhatsApp instances.
func (*EnterpriseService) RequestNewQRCode ¶
func (e *EnterpriseService) RequestNewQRCode(ctx context.Context, instanceID string) (Result, error)
RequestNewQRCode returns a fresh QR code to connect the phone.
func (*EnterpriseService) RestartInstance ¶
RestartInstance restarts an instance.
type Error ¶
type Error struct {
StatusCode int // HTTP status code
Message string // the API's "message", or the HTTP status text
Body []byte // the raw response body
}
Error is returned when the API responds with an HTTP 4xx or 5xx status.
Example ¶
package main
import (
"context"
"errors"
"fmt"
"github.com/hypersender/hypersender-go"
)
func main() {
client := hypersender.NewClient()
_, err := client.WhatsApp.SendText(context.Background(), "201234567890@c.us", "Hi", nil)
var apiErr *hypersender.Error
if errors.As(err, &apiErr) {
fmt.Println(apiErr.StatusCode, apiErr.Message)
}
}
Output:
type GenerateLinkOptions ¶
type GenerateLinkOptions struct {
Expires int `json:"expires,omitempty"` // seconds, 60-3600
Name string `json:"name,omitempty"`
Message *OTPLinkMessage `json:"message,omitempty"`
Callback *OTPLinkCallback `json:"callback,omitempty"`
}
GenerateLinkOptions are the optional fields for GenerateLink.
type GetAllContactsOptions ¶
type GetAllContactsOptions struct {
Limit int `json:"limit,omitempty"` // 1-1000, default 100
Offset int `json:"offset,omitempty"` // default 0
SortBy string `json:"sort_by,omitempty"` // "id" or "name"
SortOrder string `json:"sort_order,omitempty"` // "asc" or "desc"
}
GetAllContactsOptions are the optional fields for GetAllContacts.
type GetAllKnownLIDsOptions ¶
type GetAllKnownLIDsOptions struct {
Limit int `json:"limit,omitempty"` // default 100
Offset int `json:"offset,omitempty"` // default 0
}
GetAllKnownLIDsOptions are the optional fields for GetAllKnownLIDs.
type LinkPreview ¶
type LinkPreview struct {
Title string
Description string
URL string
Image Media // optional: MediaURL or MediaFile
}
LinkPreview is the custom preview for SendLinkCustomPreview.
type ListInstancesOptions ¶
type ListInstancesOptions struct {
UUID string `json:"filter[uuid],omitempty"`
Name string `json:"filter[name],omitempty"` // partial match
Phone string `json:"filter[phone],omitempty"`
Status string `json:"filter[status],omitempty"` // STOPPED, STARTING, WORKING, SCAN_QR_CODE, FAILED, PENDING
}
ListInstancesOptions filter ListInstances.
type ListOptions ¶
type ListOptions struct {
Filters map[string]string // e.g. {"status": "delivered"} becomes filter[status]=delivered
Sort string // e.g. "-created_at"
Include string
Page int
PerPage int
}
ListOptions filter, sort, and page SMS lists.
type Media ¶
type Media struct {
// contains filtered or unexported fields
}
Media is a file to send: a public URL (MediaURL) or an upload (MediaFile).
type MediaOptions ¶
type MediaOptions struct {
Filename string `json:"filename,omitempty"` // file name shown to the recipient
MimeType string `json:"mimetype,omitempty"`
Caption string `json:"caption,omitempty"`
ReplyTo string `json:"reply_to,omitempty"`
}
MediaOptions are the optional fields for SendFile, SendImage, and SendVideo.
type OTPLinkCallback ¶
type OTPLinkCallback struct {
Success string `json:"success,omitempty"`
Failed string `json:"failed,omitempty"`
}
OTPLinkCallback sets where the user is sent after verification.
type OTPLinkMessage ¶
type OTPLinkMessage struct {
Prompt string `json:"prompt,omitempty"`
Success string `json:"success,omitempty"`
Failed string `json:"failed,omitempty"`
Expired string `json:"expired,omitempty"`
}
OTPLinkMessage overrides the messages shown during OTP link verification.
type OTPService ¶
type OTPService struct {
// contains filtered or unexported fields
}
OTPService sends and checks one-time passwords over WhatsApp or SMS. Use it as client.OTP.
func (*OTPService) GenerateLink ¶
func (o *OTPService) GenerateLink(ctx context.Context, chatID string, opts *GenerateLinkOptions) (Result, error)
GenerateLink creates a WhatsApp OTP link the user opens to verify. The link is in data.whatsapp_link.
func (*OTPService) RequestCode ¶
func (o *OTPService) RequestCode(ctx context.Context, chatID string, opts *RequestCodeOptions) (Result, error)
RequestCode sends a one-time code to chatID.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/hypersender/hypersender-go"
)
func main() {
client := hypersender.NewClient()
ctx := context.Background()
client.OTP.RequestCode(ctx, "201234567890@c.us", &hypersender.RequestCodeOptions{Length: 6, Name: "My Shop"})
res, err := client.OTP.ValidateCode(ctx, "201234567890@c.us", "123456")
if err != nil {
log.Fatal(err)
}
fmt.Println(res["success"])
}
Output:
func (*OTPService) ValidateCode ¶
ValidateCode checks a code the user entered.
type Option ¶
type Option func(*options)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL overrides the API base URL, for example to point at a test server.
func WithEnterprise ¶
WithEnterprise sets the Enterprise API key. Default: HYPERSENDER_ENTERPRISE_API_KEY.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client used for requests. The default has a 30 second timeout.
func WithOTP ¶
WithOTP sets the OTP API key and instance ID. Defaults: HYPERSENDER_OTP_API_KEY and HYPERSENDER_OTP_INSTANCE_ID.
func WithSMS ¶
WithSMS sets the SMS API key and instance ID. Defaults: HYPERSENDER_SMS_API_KEY and HYPERSENDER_SMS_INSTANCE_ID.
func WithWhatsApp ¶
WithWhatsApp sets the WhatsApp API key and instance ID. Defaults: HYPERSENDER_WHATSAPP_API_KEY and HYPERSENDER_WHATSAPP_INSTANCE_ID.
type ReadChatOptions ¶
type ReadChatOptions struct {
Messages int // how many recent messages to mark as read
Days int // mark messages from the last N days as read
}
ReadChatOptions are the optional fields for ReadChat.
type RequestCodeOptions ¶
type RequestCodeOptions struct {
Length int `json:"length,omitempty"` // 4-10
UseNumber *bool `json:"useNumber,omitempty"` // use hypersender.Bool(true)
UseLetter *bool `json:"useLetter,omitempty"` // use hypersender.Bool(true)
AllCapital *bool `json:"allCapital,omitempty"` // use hypersender.Bool(true)
Name string `json:"name,omitempty"` // your app or company name, shown in the message
Expires int `json:"expires,omitempty"` // seconds, 60-1800
}
RequestCodeOptions are the optional fields for RequestCode.
type SMSService ¶
type SMSService struct {
// contains filtered or unexported fields
}
SMSService sends SMS through your Android phone. Use it as client.SMS.
func (*SMSService) DeleteMessage ¶
DeleteMessage deletes a message.
func (*SMSService) DeleteMessageThread ¶
func (s *SMSService) DeleteMessageThread(ctx context.Context, messageThreadID string) (Result, error)
DeleteMessageThread deletes a conversation.
func (*SMSService) EditMessageThread ¶
func (s *SMSService) EditMessageThread(ctx context.Context, messageThreadID string, isArchived bool) (Result, error)
EditMessageThread archives or unarchives a conversation.
func (*SMSService) GetHeartbeats ¶
func (s *SMSService) GetHeartbeats(ctx context.Context, opts *ListOptions) (Result, error)
GetHeartbeats lists the phone's heartbeats (app version, battery, charging) to check it is online.
func (*SMSService) ListMessageThreads ¶
func (s *SMSService) ListMessageThreads(ctx context.Context, opts *ListOptions) (Result, error)
ListMessageThreads lists conversations.
func (*SMSService) ListMessages ¶
func (s *SMSService) ListMessages(ctx context.Context, opts *ListOptions) (Result, error)
ListMessages lists messages.
func (*SMSService) SendMessage ¶
func (s *SMSService) SendMessage(ctx context.Context, to, content string, opts *SendSMSOptions) (Result, error)
SendMessage sends an SMS to a phone number such as "+201234567890".
Example ¶
package main
import (
"context"
"github.com/hypersender/hypersender-go"
)
func main() {
client := hypersender.NewClient()
client.SMS.SendMessage(context.Background(), "+201234567890", "Your order has shipped!",
&hypersender.SendSMSOptions{RequestID: "order-1042"})
}
Output:
type SendLinkCustomPreviewOptions ¶
type SendLinkCustomPreviewOptions struct {
ReplyTo string `json:"reply_to,omitempty"`
HighQuality bool `json:"high_quality,omitempty"`
}
SendLinkCustomPreviewOptions are the optional fields for SendLinkCustomPreview.
type SendLocationOptions ¶
type SendLocationOptions struct {
Title string `json:"title,omitempty"`
ReplyTo string `json:"reply_to,omitempty"`
}
SendLocationOptions are the optional fields for SendLocation.
type SendPollOptions ¶
type SendPollOptions struct {
MultipleAnswers bool // let people pick more than one option
ReplyTo string // ID of the message to reply to
}
SendPollOptions are the optional fields for SendPoll.
type SendSMSOptions ¶
type SendSMSOptions struct {
RequestID string `json:"request_id,omitempty"` // your own ID, echoed back in webhooks
ScheduleSendAt string `json:"schedule_send_at,omitempty"` // send later, e.g. "2026-12-01 09:00:00"
MaxSendAttempts int `json:"max_send_attempts,omitempty"` // retries on failure
MessageExpirationSeconds int `json:"message_expiration_seconds,omitempty"` // give up after this many seconds
}
SendSMSOptions are the optional fields for SendMessage.
type SendSeenOptions ¶
type SendSeenOptions struct {
Participant string `json:"participant,omitempty"` // in groups, the sender of the message
}
SendSeenOptions are the optional fields for SendSeen.
type SendTextOptions ¶
type SendTextOptions struct {
ReplyTo string `json:"reply_to,omitempty"` // ID of the message to reply to
LinkPreview bool `json:"link_preview,omitempty"` // show a preview for links
LinkPreviewHighQuality bool `json:"link_preview_high_quality,omitempty"` // use a high quality preview image
}
SendTextOptions are the optional fields for SendText and SendTextSafe.
type UpsertContactOptions ¶
type UpsertContactOptions struct {
LastName string `json:"last_name,omitempty"`
}
UpsertContactOptions are the optional fields for UpsertContact.
type VoiceOptions ¶
type VoiceOptions struct {
Caption string `json:"caption,omitempty"`
ReplyTo string `json:"reply_to,omitempty"`
}
VoiceOptions are the optional fields for SendVoice.
type WhatsAppService ¶
type WhatsAppService struct {
// Contacts looks up and saves WhatsApp contacts and LIDs.
Contacts *ContactsService
// contains filtered or unexported fields
}
WhatsAppService sends WhatsApp messages. Use it as client.WhatsApp.
func (*WhatsAppService) DeleteMessage ¶
func (w *WhatsAppService) DeleteMessage(ctx context.Context, chatID, messageID string) (Result, error)
DeleteMessage deletes a message for everyone.
func (*WhatsAppService) ForwardMessage ¶
func (w *WhatsAppService) ForwardMessage(ctx context.Context, chatID, messageID string) (Result, error)
ForwardMessage forwards a message to a chat.
func (*WhatsAppService) GetQueuedRequest ¶
GetQueuedRequest returns a request's status by the queued_request_uuid every send method returns.
func (*WhatsAppService) ReactToMessage ¶
func (w *WhatsAppService) ReactToMessage(ctx context.Context, chatID, messageID, reaction string) (Result, error)
ReactToMessage reacts to a message with an emoji.
func (*WhatsAppService) ReadChat ¶
func (w *WhatsAppService) ReadChat(ctx context.Context, chatID string, opts *ReadChatOptions) (Result, error)
ReadChat marks a chat's recent messages as read.
func (*WhatsAppService) SendContactCard ¶
func (w *WhatsAppService) SendContactCard(ctx context.Context, chatID string, contacts []ContactCard) (Result, error)
SendContactCard sends one or more contact cards.
func (*WhatsAppService) SendFile ¶
func (w *WhatsAppService) SendFile(ctx context.Context, chatID string, file Media, opts *MediaOptions) (Result, error)
SendFile sends a document from a URL or an upload.
func (*WhatsAppService) SendImage ¶
func (w *WhatsAppService) SendImage(ctx context.Context, chatID string, image Media, opts *MediaOptions) (Result, error)
SendImage sends an image from a URL or an upload.
Example ¶
package main
import (
"context"
"log"
"os"
"github.com/hypersender/hypersender-go"
)
func main() {
client := hypersender.NewClient()
ctx := context.Background()
// From a URL
client.WhatsApp.SendImage(ctx, "201234567890@c.us", hypersender.MediaURL("https://example.com/menu.png"),
&hypersender.MediaOptions{Caption: "Today's menu"})
// From a local file
f, err := os.Open("invoice.pdf")
if err != nil {
log.Fatal(err)
}
defer f.Close()
client.WhatsApp.SendFile(ctx, "201234567890@c.us", hypersender.MediaFile("invoice.pdf", f), nil)
}
Output:
func (*WhatsAppService) SendLinkCustomPreview ¶
func (w *WhatsAppService) SendLinkCustomPreview(ctx context.Context, chatID, text string, preview LinkPreview, opts *SendLinkCustomPreviewOptions) (Result, error)
SendLinkCustomPreview sends a link with your own preview title, description, and image.
func (*WhatsAppService) SendLocation ¶
func (w *WhatsAppService) SendLocation(ctx context.Context, chatID string, latitude, longitude float64, opts *SendLocationOptions) (Result, error)
SendLocation sends a location pin.
func (*WhatsAppService) SendPoll ¶
func (w *WhatsAppService) SendPoll(ctx context.Context, chatID, name string, options []string, opts *SendPollOptions) (Result, error)
SendPoll sends a poll.
func (*WhatsAppService) SendSeen ¶
func (w *WhatsAppService) SendSeen(ctx context.Context, chatID, messageID string, opts *SendSeenOptions) (Result, error)
SendSeen marks a message as seen (blue ticks).
func (*WhatsAppService) SendText ¶
func (w *WhatsAppService) SendText(ctx context.Context, chatID, text string, opts *SendTextOptions) (Result, error)
SendText sends a text message. chatID looks like "201234567890@c.us".
func (*WhatsAppService) SendTextSafe ¶
func (w *WhatsAppService) SendTextSafe(ctx context.Context, chatID, text string, opts *SendTextOptions) (Result, error)
SendTextSafe sends a text message with human-like pacing and typing to lower the risk of a block.
func (*WhatsAppService) SendVideo ¶
func (w *WhatsAppService) SendVideo(ctx context.Context, chatID string, video Media, opts *MediaOptions) (Result, error)
SendVideo sends a video from a URL or an upload.
func (*WhatsAppService) SendVoice ¶
func (w *WhatsAppService) SendVoice(ctx context.Context, chatID string, voice Media, opts *VoiceOptions) (Result, error)
SendVoice sends a voice note from a URL or an upload.
func (*WhatsAppService) StarMessage ¶
func (w *WhatsAppService) StarMessage(ctx context.Context, chatID, messageID string, star bool) (Result, error)
StarMessage stars (star=true) or unstars a message.
func (*WhatsAppService) StartTyping ¶
StartTyping shows "typing..." in a chat.
func (*WhatsAppService) StopTyping ¶
StopTyping stops showing "typing..." in a chat.