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 8090Program 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; supportsvalidate(regex),on_invalidandexpect contact.set $session.x = exprβ store a value in session/user scope.if β¦ else/matchβ branching on conditions.goto "flow"β jump to another flow;endstops.call @connector.actionβ invoke a managed connector, optionallystorethe result and branchon_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 = 300Adapters
| Channel | Status | Transport |
|---|---|---|
| Telegram | β Stable | Long-poll (Bot API) |
| Instagram DM | β Supported | Meta Graph webhook |
| β Supported | WhatsApp 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.