Whatsmeow is a Go library for the WhatsApp web multidevice API.

whatsmeow

godocs.io

whatsmeow is a Go library for the WhatsApp web multidevice API.

This was initially forked from go-whatsapp (MIT license), but large parts of the code have been rewritten for multidevice support. Parts of the code are ported from WhatsappWeb4j and Baileys (also MIT license).

Discussion

Matrix room: #whatsmeow:maunium.net

Usage

The godoc includes docs for all methods and event types. There's also a simple example at the top.

Also see mdtest for a CLI tool you can easily try out whatsmeow with.

Features

Most core features are already present:

  • Sending messages to private chats and groups (both text and media)
  • Receiving all messages
  • Managing groups and receiving group change events
  • Joining via invite messages, using and creating invite links
  • Sending and receiving typing notifications
  • Sending and receiving delivery and read receipts
  • Reading app state (contact list, chat pin/mute status, etc)
  • Sending and handling retry receipts if message decryption fails

Things that are not yet implemented:

  • Writing app state (contact list, chat pin/mute status, etc)
  • Sending status messages or broadcast list messages (this is not supported on WhatsApp web either)
  • Calls
Owner
Tulir Asokan
Go/Python/JS developer, Ubuntu/GNOME user, Sysadmin, Star Trek, Stargate & Doctor Who fan
Tulir Asokan
Comments
  • Issue when send first message

    Issue when send first message

    hello , i am getting weird problem . when ever i send message to any number first time its shows error to receiver's mobile . from 2nd message onwords its working fine . shows waiting for this message.This may takes a while.

    139803571-fea86aab-5f6e-4756-a9c2-01ef308c8c1b

  • Button message not working

    Button message not working

    Hello, Today button message stopped working . may be Baileys patch work
    https://github.com/adiwajshing/Baileys/commit/9f3b00d58d4f6b1527db42069acafff01123cbf8

    can you please implement it .

    /**

    • this is an experimental patch to make buttons work
    • Don't know how it works, but it does for now */
    export const patchMessageForMdIfRequired = (message: proto.IMessage) => {
    	const requiresPatch = !!(
    		message.buttonsMessage
    		// || message.templateMessage
    		|| message.listMessage
    	)
    	if(requiresPatch) {
    		message = {
    			viewOnceMessage: {
    				message: {
    					messageContextInfo: generateContextInfo(),
    					...message
    				}
    			}
    		}
    	}
    
    	return message
    }
    
  • PSA Error 405 - Please don't spam the issue section, Tulir is aware of the problem.

    PSA Error 405 - Please don't spam the issue section, Tulir is aware of the problem.

    Seems to happen to all repos right now.

    Connecting will throw [Client WARN] Unknown connect failure: <failure location="vll" reason="405"/>

    Let's see where this is going. Please comment if you found something that may help.

  • go-whatsapp REST API

    go-whatsapp REST API

    Dear Tulir. I would like to share with you my previous work on the go-WhatsApp, I made a restful API that supports MySQL, webhooks, but it is all around go-whatsapp which it is not supporting (MD)

    I would like to see my work along with your work which will help others to start their WhatsApp bot right away. but I have some health problems which prevent me to work and update the lib.

    https://github.com/beshoo/go-whatsapp-rest-api

    Please have a look..

    Regards

  • List and Button messages appearing only at the sender account

    List and Button messages appearing only at the sender account

    I've the below code:

    package utils
    
    import (
    	"context"
    	"strconv"
    	"wa/Enum"
    	"wa/api"
    	"wa/global"
    
    	waProto "go.mau.fi/whatsmeow/binary/proto"
    	"google.golang.org/protobuf/proto"
    )
    
    func MainMenu(sender, welcome string) {
    	msg := &waProto.ListMessage{
    		Title:       proto.String(welcome),
    		Description: proto.String("يرجى تحديد سبب التواصل"),
    		ButtonText:  proto.String("أنقر هنا  👈"),
    		ListType:    waProto.ListMessage_SINGLE_SELECT.Enum(),
    		Sections: []*waProto.ListMessage_Section{
    			{
    				Title: proto.String("لدي إستفسار بخصوص:"),
    				Rows: []*waProto.ListMessage_Row{
    					{
    						RowId: proto.String(strconv.Itoa(Enum.Discount)),
    						Title: proto.String("عمادة القبول والتسجيل"),
    					},
    					{
    						RowId: proto.String(strconv.Itoa(Enum.Discount)),
    						Title: proto.String("عمادة شؤون المكتبات"),
    					},
    					{
    						RowId: proto.String(strconv.Itoa(Enum.Discount)),
    						Title: proto.String("مواقع كليات وفروع جامعة الملك خالد"),
    					},
    				},
    			},
    		},
    	}
    
    	targetJID, ok := ParseJID(sender)
    	if !ok {
    		return
    	}
    
    	send, err := api.Client.SendMessage(context.Background(), targetJID, "", &waProto.Message{
    		ListMessage: msg,
    	}) // jid = recipient
    	if err != nil {
    		global.Log.Errorf("Error sending message: %v", err)
    	} else {
    		global.Log.Infof("Message sent (server timestamp: %s)", send)
    	}
    
    	send2, err := api.Client.SendMessage(context.Background(), targetJID, "", &waProto.Message{
    		Conversation: proto.String("Hello, World!"),
    	})
    	if err != nil {
    		global.Log.Errorf("Error sending message: %v", err)
    	} else {
    		global.Log.Infof("Message sent (server timestamp: %s)", send2)
    	}
    
    }
    

    But the list message is seen only at th esender account (i.e. the account connected to the app using whatsmeow package) and not seeing it at the recieved account, same happen with Button Message, but sending a conversation message is different as it is appearing at both accounts

    	msg := &waProto.ButtonsMessage{
    		ContentText: proto.String("لدي إستفسار بخصوص:"),
    		HeaderType:  waProto.ButtonsMessage_EMPTY.Enum(),
    		Buttons: []*waProto.ButtonsMessage_Button{
    			{
    				ButtonId:       proto.String(strconv.Itoa(Enum.Yes)),
    				ButtonText:     &waProto.ButtonsMessage_Button_ButtonText{DisplayText: proto.String("نعم")},
    				Type:           waProto.ButtonsMessage_Button_RESPONSE.Enum(),
    				NativeFlowInfo: &waProto.ButtonsMessage_Button_NativeFlowInfo{},
    			},
    			{
    				ButtonId:       proto.String(strconv.Itoa(Enum.No)),
    				ButtonText:     &waProto.ButtonsMessage_Button_ButtonText{DisplayText: proto.String("لا")},
    				Type:           waProto.ButtonsMessage_Button_RESPONSE.Enum(), //proto.ButtonsMessage_Button_Type.Enum,
    				NativeFlowInfo: &waProto.ButtonsMessage_Button_NativeFlowInfo{},
    			},
    		},
    	}
    
    	send, err := api.Client.SendMessage(context.Background(), targetJID, "", &waProto.Message{
    		ButtonsMessage: msg,
    	})
    

    image

  • Image message unable to preview

    Image message unable to preview

    I followed the documentation and perform a simple image upload but the image (bottom message) sent was unable to preview like we sending the image manually (top message)

    NOTE: the receiver has no saved contact of the sender my code to reproduce the issue:

            jpegImageFile, jpegErr := os.Open("/home/user/Desktop/beaches.jpeg")
    	if jpegErr != nil{
    		// Handle error
    	}
    	defer jpegImageFile.Close()
    
    	jpegFileinfo, _ := jpegImageFile.Stat()
    	var jpegSize int64 = jpegFileinfo.Size()
    	jpegBytes := make([]byte, jpegSize)
    
    	jpegBuffer := bufio.NewReader(jpegImageFile)
    	_, jpegErr = jpegBuffer.Read(jpegBytes)
    
            resp, err := client.Upload(context.Background(), jpegBytes, whatsmeow.MediaImage)
    	// handle error
    
            my_num := ""
    
    	if err == nil {
    
    		imageMsg := &waProto.ImageMessage{
    				Caption:  proto.String("Hello, world!"),
    				Mimetype: proto.String("image/jpeg"), // replace this with the actual mime type
    				// you can also optionally add other fields like ContextInfo and JpegThumbnail here
    				ThumbnailDirectPath: &resp.DirectPath,
    				ThumbnailSha256: resp.FileSHA256,
    				ThumbnailEncSha256: resp.FileEncSHA256,
    				JpegThumbnail: jpegBytes,
    				
    
    				Url:           &resp.URL,
    				DirectPath:    &resp.DirectPath,
    				MediaKey:      resp.MediaKey,
    				FileEncSha256: resp.FileEncSHA256,
    				FileSha256:    resp.FileSHA256,
    				FileLength:    &resp.FileLength,
    				
    		}
    		_, err = client.SendMessage(context.Background(), types.NewJID(my_num, "s.whatsapp.net"), "", &waProto.Message{
    				ImageMessage: imageMsg,
    				// ExtendedTextMessage: &waProto.ExtendedTextMessage{
    					
    				// 	ThumbnailDirectPath: &resp.DirectPath,
    				// 	ThumbnailSha256: resp.FileSHA256,
    				// 	ThumbnailEncSha256: resp.FileEncSHA256,
    				// 	JpegThumbnail: jpegBytes,
    				// },
    		})
    	}
    
    
  • Is this library be used for production? | Why, what purpose, how many numbers?

    Is this library be used for production? | Why, what purpose, how many numbers?

    Anyone using this library for production?

    Does anyone in a company or otherwise use this library? Can anyone say why, for what purpose and how many numbers they use this library?

  • Issue when receive first message

    Issue when receive first message

    Error on decrypting when a new contact comes in contact without being in the contact list

    events.ReceiptType events.ReceiptTypeRetry

    // ReceiptTypeRetry means the message was delivered to the device, but decrypting the message failed.

    how to solve this?

  • How to get Conversations when I login in

    How to get Conversations when I login in

    When I login in whatsapp ,Now I use events.HistorySync to get the Conversations , Is this right? I see six HistorySyncType , what does every one means? image image

  • No new message notification on phone if message received in whatsmeow

    No new message notification on phone if message received in whatsmeow

    Hi! For some reason, the notification of the received message does not appear on the phone if the message is also received in whatsmeow. How can I get notifications for new messages on my phone?

  • Get group picture by new group id

    Get group picture by new group id

    Hello! I'm trying to get a group picture using client.GetProfilePictureInfo(jid)

    if I get a picture for the old group in jid which contains "-" then everything is fine, I get the picture, but if for the new group, where there are just 18 digits, then an error :( PS: @g.us в jid added.

  • Add file logging to the waLog package (util/log.go)

    Add file logging to the waLog package (util/log.go)

    Noteworthy changes:

    • waLog.File() returns a file logger using the arguments:
      • module (string), just like the Stdout() logger
      • filename (string): output file
      • reopen (bool): should the logfile be reopened if an external script rotates it away
      • append (bool): overwrite or append new logs
    • Literal strings like "DEBUG" are now constants
    • The methods that a Logger interface must fulfill (Errorf(), Debugf() and friends) now return an error (which is non-nil if a logfile can't be reopened after disappearing)
    • Common functionality between the loggers is now in helpers, like shouldOutput() (to prevent emitting when a log level is too low) or timestamp() (consistent time stamping in the Stdout() and File() loggers)
    • The examples have been modified to show how logging to a file can be configured
    • util/log_test.go is added.

    Closes #244

  • failed to send usync query: websocket not connected

    failed to send usync query: websocket not connected

    When I use IsOnWhatsApp to validate a phone number is register on whatsapp , always raise panic failed to send usync query: websocket not connected . I have login in whatsapp. this method is in user.go image

  • Remove local replace directive from go.mod

    Remove local replace directive from go.mod

    Replace directives disable external go run ... support:

    % go run github.com/tulir/whatsmeow/mdtest@latest
    go: github.com/tulir/whatsmeow/mdtest@latest (in github.com/tulir/whatsmeow/[email protected]):
    	The go.mod file for the module providing named packages contains one or
    	more replace directives. It must not contain directives that would cause
    	it to be interpreted differently than if it were the main module.
    

    A better way to develop multiple modules concurrently is with Go 1.18 workspaces[0].

    [0] https://go.dev/blog/get-familiar-with-workspaces

  • Add `GetDeviceByUser`

    Add `GetDeviceByUser`

    This functionality could be very helpful:

    const getUserDeviceQuery = getAllDevicesQuery + " WHERE jid LIKE $1"
    
    // GetUserDevice finds the device with the specified User in the database.
    //
    // If the device is not found, nil is returned instead.
    //
    // Note that the parameter usually must be an AD-JID.
    func (c *Container) GetUserDevice(jid types.JID) (*store.Device, error) {
            ujid := fmt.Sprintf("%s.%d:%@%s", jid.User, jid.Agent, jid.Server)
    	sess, err := c.scanDevice(c.db.QueryRow(getUserDeviceQuery, ujid))
    	if errors.Is(err, sql.ErrNoRows) {
    		return nil, nil
    	}
    	return sess, err
    }
    
  • Hash list problem

    Hash list problem

    Some message has lost because i received this message in log

    "09:59:04.478 [Database WARN] Server returned different participant list hash when sending to [email protected]. Some devices may not have received the message."
    

    How should I handle this case for the message to be sent?

Simple RESTful API for WhatsApp in Golang (using the Whatsmeow multi device library)
Simple RESTful API for WhatsApp in Golang (using the Whatsmeow multi device library)

WUZAPI WuzAPI is an implementation of @tulir/whatsmeow library as a simple RESTful API service with multiple device support and concurrent sessions. W

Dec 30, 2022
go-whatsapp-rest-API is a Go library for the WhatsApp web which use Swagger as api interface

go-whatsapp-rest-API go-whatsapp-rest-API is a Go library for the WhatsApp web which use Swagger as api interface Multi-devices (MD) Support. This ver

Dec 15, 2022
Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Mar 19, 2022
WhatsApp Web API

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Jan 7, 2023
WhatsAppExpenseTracker - Way to track expenses using whatsapp group

WhatsAppExpenseTracker Way to track expenses using whatsapp group One needs to c

Jan 4, 2022
Go library for the Spotify Web API

go-spotify Simple Go library for the Spotify Web API Installation go get github.com/rapito/go-spotify/spotify How-to-use Get Requests import "fmt

Nov 18, 2022
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple Weather API Simple weather api app created using golang and Open Weather

Feb 6, 2022
Go library for accessing the MyAnimeList API: http://myanimelist.net/modules.php?go=api

go-myanimelist go-myanimelist is a Go client library for accessing the MyAnimeList API. Project Status The MyAnimeList API has been stable for years a

Sep 28, 2022
Backgammon Web API. Sophisticed neural net based multi-ply evalution engine for Backgammon moves

Backgammon Web API. Sophisticed neural net based multi-ply evalution engine for Backgammon moves.

Dec 25, 2022
Awspowertoggle - Web UI and API for quickly starting and stopping AWS environments
Awspowertoggle - Web UI and API for quickly starting and stopping AWS environments

aws-power-toggle web UI and API for quickly starting and stopping AWS environmen

Feb 23, 2022
Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.

YNAB API Go Library This is an UNOFFICIAL Go client for the YNAB API. It covers 100% of the resources made available by the YNAB API. Installation go

Oct 6, 2022
An API client for the Notion API implemented in Golang

An API client for the Notion API implemented in Golang

Dec 30, 2022
lambda-go-api-proxy makes it easy to port APIs written with Go frameworks such as Gin to AWS Lambda and Amazon API Gateway.

aws-lambda-go-api-proxy makes it easy to run Golang APIs written with frameworks such as Gin with AWS Lambda and Amazon API Gateway.

Jan 6, 2023
A API scanner written in GOLANG to scan files recursively and look for API keys and IDs.

GO FIND APIS _____ ____ ______ _____ _ _ _____ _____ _____ _____ / ____|/ __ \ | ____|_ _| \ | | __ \ /\ | __ \_

Oct 25, 2021
The NVD API is an unofficial Go wrapper around the NVD API.

NVD API The NVD API is an unofficial Go wrapper around the NVD API. Supports: CVE CPE How to use The following shows how to basically use the wrapper

Jan 7, 2023
A Wrapper Client for Google Spreadsheet API (Sheets API)

Senmai A Wrapper Client for Google Spreadsheet API (Sheets API) PREPARATION Service Account and Key File Create a service account on Google Cloud Plat

Nov 5, 2021
💾 Wolke API is the API behind Wolke image storage and processing aswell as user management

?? Wolke API Wolke API is the API behind Wolke image storage and processing aswell as user management Deploying To deploy Wolke Bot you'll need podman

Dec 21, 2021
Upcoming mobiles api (UpMob API)

upcoming_mobiles_api (UpMob API) UpMob API scraps 91mobiles.com to get devices i

Dec 21, 2021
Arweave-api - Arweave API implementation in golang

Arweave API Go implementation of the Arweave API Todo A list of endpoints that a

Jan 16, 2022