Documentation

IMB is a small language for chatbots and the platform that generates, runs and manages them. Non-technical owners use the builder; developers can write .imb files directly.

Quick start

The fastest path is the no-code builder: describe your business and launch. To work in code:

# 1. write bot.imb   2. configure   3. run
imb run bot.imb --adapter telegram --config imb-conf.ini

# inspect the compiled IR
imb compile bot.imb

# serve the engine over HTTP (used by the dashboard test-chat)
imb serve bot.imb --config imb-conf.ini --port 8090

Program structure

A program declares metadata, channels, integrations, localized strings, event handlers and flows.

meta { name "Davron Barbershop"  language "uz"  timezone "Asia/Tashkent" }
config { welcome_flow "menu"  fallback_flow "unknown" }

platform telegram  { token        env("TG_TOKEN") }
platform instagram { access_token env("IG_TOKEN") }

integration gcal      { connector "google-calendar" account env("CONNECTOR_GCAL") }
integration reminders { connector "imb-reminders" }
integration notify    { connector "imb-notify" }

Handlers & flows

Handlers map a trigger (command, callback action, regex, event or wildcard) to a flow or inline block.

on /start -> "menu"
on action "menu_book" -> "book"
on action ~^svc_(.+)$~ { set $session.service = $input.match[1]  goto "show_slots" }
on * -> "unknown"

flow "menu" {
  reply {
    text "Welcome! Choose:"
    buttons [
      "βœ‚οΈ Haircut β€” 50 000" -> action "svc_haircut"
      "πŸ“ž Contact"          -> action "menu_contact"
    ]
  }
}

Statements

  • reply β€” send text, static/dynamic buttons or a photo.
  • ask β€” prompt, then suspend until the user answers; supports validate (regex), on_invalid and expect contact.
  • set $session.x = expr β€” store a value in session/user scope.
  • if … else / match β€” branching on conditions.
  • goto "flow" β€” jump to another flow; end stops.
  • call @connector.action β€” invoke a managed connector, optionally store the result and branch on_error.
  • emit "event" β€” publish a domain event.
flow "collect" {
  ask {
    prompt     "Your phone (+998…):"
    store   -> $session.phone
    validate   ~^\+?998\d{9}$~
    on_invalid "Please enter a valid +998 number."
    expect     contact
  }
  reply "Got it: #{$session.phone}"
}

Variables & interpolation

Scopes: $session.* (per conversation), $user.* (per user, e.g. $user.lang, $user.id), $bot.* (admins, business facts), $input.text, $input.match[n], $event.*. Interpolate with #{…}.

reply "#{$session.name}, your #{$session.service} is at #{$session.slot}."

Localization

Define strings per language; $str.key resolves against $user.lang.

strings {
  pick_lang { uz "Tilni tanlang:" ru "Π’Ρ‹Π±Π΅Ρ€ΠΈΡ‚Π΅ язык:" en "Choose a language:" }
}
flow "start" { reply $str.pick_lang }

Configuration (imb-conf.ini)

Secrets and runtime wiring live here, never in the .imb source. Any value may be env:VAR.

[telegram]
bot_token = env:TG_TOKEN

[bot]
id = barber-demo
admins = 11111111, 22222222   ; -> $bot.admins

[gateway]
url    = https://your-host        ; omit -> offline MockGateway
secret = shared-hmac-secret

[store]
backend = sled                    ; sled | memory
path    = ./data/sessions

[reminders]
enabled = true
interval_secs = 300

Adapters

ChannelStatusTransport
Telegramβœ… StableLong-poll (Bot API)
Instagram DMβœ… SupportedMeta Graph webhook
WhatsAppβœ… SupportedWhatsApp Cloud API webhook

Connectors & the gateway

An .imb file never holds OAuth tokens. call @gcal.create_event is forwarded (HMAC-signed) to the managed gateway, which holds the owner's authorized credentials and performs the real call. Built-in connectors: gcal (Google Calendar), reminders, leads, notify.

Ready to build?
Describe your business β€” live in minutes.
Build a bot