TelegramEx

Elixir library for building Telegram bots with a macro-based API.

GitHub Actions Workflow StatusHex VersionLast commitStarsLicenseHex.pm Downloads

Installation

def deps do
[
{:telegram_ex, "~> 1.3.0"}
]
end

Quickstart

Configure your bot token in config/runtime.exs:

import Config
config :telegram_ex,
my_bot: System.fetch_env!("MY_BOT_TELEGRAM_TOKEN")

Define a minimal bot:

defmodule MyBot do
use TelegramEx, name: :my_bot
def handle_message(%{text: "/start", chat: chat}, ctx) do
ctx
|> Message.text("Hello from TelegramEx.")
|> Message.send(chat["id"])
end
def handle_callback(_callback, _ctx), do: :ok
end

Start it under your supervision tree:

children = [MyBot]
Supervisor.start_link(children, strategy: :one_for_one)

Guides

Features

Documentation

See HexDocs for API reference and guides.

Star History Chart