telega_wisp
Wisp webhook adapter for Telega Telegram Bot Library.
Installation
gleam add telega_wisp
Usage
telega_wisp provides a handle_bot middleware that plugs into your Wisp request handler. It validates the secret token, decodes incoming Telegram updates, and dispatches them to your bot.
import wisp.{type Request, type Response}
import telega.{type Telega}
import telega_wisp
fn handle_request(req: Request, telega: Telega(session, error)) -> Response {
use <- telega_wisp.handle_bot(telega:, req:)
// Your other routes here...
wisp.not_found()
}
The middleware will:
- Check if the request matches the bot’s webhook path
- Validate the
x-telegram-bot-api-secret-tokenheader - Decode the update and pass it to the bot asynchronously
- Return
200 OKimmediately so Telegram doesn’t retry
Requirements
- Gleam >= 1.12.0
- Erlang target only