Skip to content

g4s8/openbots

Repository files navigation

Telegram Bot framework with declarative YAML specification.

CI Docker Pulls

Example

Write bot specification in bot.yml file:

bot:
  handlers:
    - on:
        message:
          command: start
      reply:
        - message:
            text: Hello
            markup:
              keyboard:
                - ["Hello!"]
                - ["How are you?"]
    - on:
        message: "Hello!"
      reply:
        - message:
            text: "Hi!"
    - on:
        message: "How are you?"
      reply:
        - message:
            text: "I'm fine, thank you"

Create new Telegram bot and get its token: https://core.telegram.org/bots#6-botfather

Provide this token to docker image as BOT_TOKEN environment.

Run your bot:

docker run \
    -v $PWD/bot.yml:/w/config.yml \
    --env BOT_TOKEN="$BOT_TOKEN" \
    g4s8/openbots:latest

Quick start

See quick start guide to create Telegram bot in minutes.

Documentation

The full documentation is available here: g4s8.github.io/openbots/documentation.

About

This is a Telegram bot framework which allows you to write low-code bot project. You delcare the bot in YAML specification file and start the bot using CLI or Docker image.

Full feature list:

  • handle text messages
  • handle bot commands
  • handle inline queries callbacks (buttons)
  • reply with text messages
  • reply callbacks
  • reply with inline buttons
  • change keyboard layout (reply markup)
  • reply with Markup, MarkupV2, HTML messages
  • switch context, handle context-based updates
  • keep state data and interpolate state in replies
  • edit message
  • reply with images
  • handle image messages
  • delete messages
  • API:
    • send message to particular user
  • call webhook on update
  • database storage
  • payments
  • validation
  • state operations

Persistence

Bot can keep its state in two modes:

  • memory - store all data in memory
  • database - connect PostgreSQL database

For persistence configuration see documentation.

Extending

This bot could be extended with custom handlers on Go.