WhatsApp + Kotlin

WAHA provides a private, self-hosted, and free HTTP API to seamlessly integrate and automate WhatsApp using Kotlin.

Send messages, manage chats, and streamline workflows effortlessly with a simple API!

WhatsApp + Kotlin

How To Use?

Run WAHA
1. Start WAHA
Run one command in the terminal on your own laptop or server
Scan QR
2. Pair Number
Connect your or any other number by scanning QR code

WhatsApp + Kotlin

WhatsApp Channel Logo

Install Dependencies

build.gradle.kts
dependencies {
    implementation("io.ktor:ktor-server-core:2.3.5")
    implementation("io.ktor:ktor-server-netty:2.3.5")
    implementation("io.ktor:ktor-client-core:2.3.5")
    implementation("io.ktor:ktor-client-cio:2.3.5") // Optional HTTP client
}
Free

Send Message

import io.ktor.client.*
import io.ktor.client.request.*
import io.ktor.http.*

suspend fun sendMessage() {
    val client = HttpClient()
    val response =
        client.post("http://localhost:3000/api/sendText") {
            contentType(ContentType.Application.Json)
            setBody(
                mapOf(
                    "session" to "default",
                    "chatId" to "12132132130@newsletter",
                    "text" to "Hi there!"
                )
            )
        }
    println(response.status)
}
API

Receive Message

import io.ktor.application.*
import io.ktor.features.ContentNegotiation
import io.ktor.jackson.jackson
import io.ktor.request.*
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*

fun main() {
    embeddedServer(Netty, port = 8080) {
        install(ContentNegotiation) {
            jackson()
        }
        routing {
            post("/bot") {
                val data = call.receive<Map<String, Any>>()
                if (data["event"] == "message") {  // Fixed condition logic
                    processMessage(data["payload"])
                }
                call.respondText("OK")
            }
        }
    }.start(wait = true)
}

fun processMessage(payload: Any?) {
    println("Processing message: $payload")
}

How To Start?

⚡ Quick Start and 🧩 Kotlin Integration documentation to get started!

Why WAHA?

Free

It's free!

WAHA Core version is always free, no limits in messages or time!
WAHA Plus version have no licence expiration!

Servers

Self-hosted solution

No strings to suspicious SaaS WhatsApp API solutions. Install it on your own server!

API

HTTP / REST API

Use your own favorite language - Python, JavaScript, PHP, C#, Clojure, or PowerShell.
PowerShell, really? Are you insane?! Choose another language, dude.

Document

Scalable

You can easily run 1 session to automate your WhatsApp and scale it to 500 sessions to provide SaaS solution!

Easy

Easy & Simple

You can run the API in a click!* Documentation has a lof examples and how-to guides.
*It's actually "a command", not a click.

Checked

No blocking

Under the hood it runs a real instance of Whatsapp Web to avoid getting blocked.
WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.