WAHA + Go

Install Dependencies

go get -u github.com/gofiber/fiber/v2

Send Message

package main

import (
    "bytes"
    "encoding/json"
    "net/http"
)

type Message struct {
    Session string `json:"session"`
    ChatID  string `json:"chatId"`
    Text    string `json:"text"`
}

func main() {
    url := "http://localhost:3000/api/sendText"
    msg := Message{Session: "default", ChatID: "12132132130@c.us", Text: "Hi there!"}
    jsonData, _ := json.Marshal(msg)

    resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
}

Receive Message

package main

import (
    "fmt"
    "github.com/gofiber/fiber/v2"
)

func main() {
    app := fiber.New()

    app.Post("/bot", func(c *fiber.Ctx) error {
        var data map[string]interface{}
        if err := c.BodyParser(&data); err != nil {
            return err
        }

        if event, ok := data["event"].(string); ok && event == "message" {
            fmt.Println("Received message:", data["payload"])
            // Process message...
        }
        return c.SendString("OK")
    })

    app.Listen(":3000")
}