This page is machine-translated from the Russian original. If something reads oddly, the Russian version is the source of truth — open an issue.
A CLI utility for quickly creating and configuring projects based on the multi-platform umbot framework. It lets you
generate a ready-made structure for voice skills (Alice, Sber SmartApp, Marusia) or chatbots (Telegram, VK, Viber,
MAX) with a single command.
It also lets you:
Install the framework and create a new project:
npx umbot create my-bot
cd my-bot
npm install
npm run build
npm start
npm install creates package-lock.json. Keep it in the repository together with the source code: it pins the tested dependency versions for CI and Docker builds.
After that, the application is available locally. To run it, use npm run build && npm start — this applies both to the default/quiz templates and to projects generated with create from-flow. For interactive debugging in the console (without an HTTP server), create a project in the dev mode — then index.ts uses BotTest and the test() method.
| Command | Description | Parameters |
|---|---|---|
create |
Create a new project | <project-name> or <config-file.json> |
create from-flow |
Create a project from the visual editor | <flow.json> [--output ./path] [--usecloud] [--force] |
validate |
Check that flow.json is valid | <flow.json> |
stats |
Aggregate metrics from a log | --log <path> |
generateenv |
Generate a .env file in the current folder | [--force] |
doctor |
Check the project, tokens and webhooks | [--env <path>] [--offline] |
webhook |
Register a Telegram/MAX webhook with a secret | <telegram|max> <https-url> |
add docker |
Add a Dockerfile and .dockerignore to the current folder | - |
add deploy |
Add .github/workflows/deploy.yml | - |
add env |
Generate .env in the current folder | [--force] |
add platform |
A scaffold of your own platform adapter with a test | <Name> [--force] |
add db |
A scaffold of a database adapter with a test | <Name> [--force] |
add middleware |
A middleware scaffold with a test | <name> [--force] |
-v, version |
Show the CLI version | - |
add platform, add db, add middlewareThe commands are run in the project root (where the src/ folder is) and create a module together with a test:
| Command | Files |
|---|---|
npx umbot add platform <Name> |
src/platforms/<Name>Adapter.ts, <Name>Adapter.test.ts |
npx umbot add db <Name> |
src/db/<Name>DbAdapter.ts, <Name>DbAdapter.test.ts |
npx umbot add middleware <n> |
src/middleware/<name>.ts, <name>.test.ts (a factory function) |
The name is written in Latin letters: discord, my-chat, Postgres. You can omit the Adapter suffix. For a platform adapter,
platformName is derived from the name (my-chat → my_chat).
The scaffold compiles and passes its tests right away. The places you need to fill in for your platform or database are marked
with a TODO comment:
Request (the request has a time limit). Unknown events get a response without calling the commands: on an error the platform
would redeliver the update. You need to fill in the request format, the API address, authorization and the button format;userId on
different platforms (uniqueKeys);The tests are written with the built-in node:test and need no extra dependencies. Run them with the command the CLI
prints after generation:
npx umbot add platform discord
npm run build && node --test dist/platforms/DiscordAdapter.test.js
The CLI does not change src/index.ts: it prints the connection lines (bot.use(...)) to the console. Existing files are not overwritten without
--force. How each method works is described in the guides on the
platform adapter,
DB adapter and
middleware.
webhook commandnpx umbot webhook <telegram|max> <https-url> enables webhook signature verification with a single command. Run it
in the project folder: the token is taken from .env (TELEGRAM_TOKEN / MAX_TOKEN) or the environment. The command generates
a secret, registers the webhook with it right away (setWebhook for Telegram, POST /subscriptions for MAX) and saves the secret
to .env as TELEGRAM_WEBHOOK_SECRET / MAX_WEBHOOK_SECRET. The framework reads these variables itself and starts
rejecting requests without the correct secret. The secret is written to .env only after a successful registration, and if it is already
there, the existing one is used. For VK, the secret key is set in the community's Callback API settings
(VK_SECRET_KEY in .env).
npx umbot webhook telegram https://bot.example.com/webhook
doctor commandnpx umbot doctor in the project folder checks whether the bot is ready to run and prints a report:
umbot package is installed;.env exists and is listed in .gitignore (otherwise tokens get into git — this is an error);.env and the environment work: a request to the API (Telegram getMe, MAX GET /me, VK
groups.getById, Viber get_account_info, Alice — the file upload quota). For SmartApp and Marusia only
the presence of the token is checked;bot.startPolling().Tokens do not get into the report. --offline disables API requests, --env <path> sets another .env file. On
errors the command exits with code 1 — you can run it in CI before deploying.
npx umbot doctor
create command flags| Flag | Description |
|---|---|
--minimal |
Creates a minimal working project without a controller class: all the logic is described directly in index.ts with addCommand (the project configs are generated as usual). Suitable for a quick prototype. Works only with the default type. |
--prod |
Creates a production-ready project: Dockerfile, .dockerignore and .github/workflows/deploy.yml. The .env file is created in every project, see below. |
--usecloud |
Generates a Yandex Cloud Functions application: adds serverless.yml, disables the local HTTP listener. Applies only to create from-flow. |
--force |
Allows overwriting a non-empty target directory. Otherwise the CLI stops with an error so as not to erase your files. |
💡 Important: the
--minimalflag does not apply to thequiztype, since a quiz requires complex logic and state storage.
The .env file. A project created by create always reads .env (env: './.env' in src/config/*Config.ts), and the CLI
creates it with empty variables for tokens, webhook secrets and MongoDB — fill in the ones you need. Empty values are
skipped by the framework. An existing .env is not overwritten. If there is no file (Docker, serverless), the variables are taken
from the process environment. The generateenv and add env commands write the same template to the current folder.
To quickly create an application, run the following command:
npx umbot create my-bot-project
After the command runs, the application is created, and all that is left is to run:
npm i
npm run build
npm start
To quickly create an application with additional settings, follow these steps.
Create a config.json file
{
"name": "quiz-bot",
"type": "quiz",
"mode": "dev",
"path": "./bots/quiz",
"config": {
"json": "./data",
"error_log": "./logs",
"isLocalStorage": true,
"tokens": {
"alisa": {
"token": "..."
},
"telegram": {
"token": "..."
}
}
},
"isEnv": true
}
⚠️ Security: fields such as
tokens.*.token,db.host,db.pass, etc. in your JSON config are placeholder values. Do not keep real tokens in*.json(it will get into git); use.envor environment variables. The generated.envis automatically added to.gitignore, but if you create it manually, make sure.gitignorecovers it.
Then run:
npx umbot create config.json
The utility creates a project in the ./bots/quiz folder with all the specified settings.
npm i
npm run build
npm start
When creating a project from JSON, you can pass the following parameters:
interface ProjectConfig {
// Project name (required)
name: string;
// Project type: "default" or "quiz"
type?: 'default' | 'quiz';
// Mode: "prod", "dev", "dev-online", "build"
mode?: 'prod' | 'dev' | 'dev-online' | 'build';
// Application configuration (IAppConfig from umbot)
// In the CLI this is an object merged with the template's default config.
config?: Record<string, unknown>;
// Platform parameters/intents (IAppParam from umbot)
// In the CLI this is an object merged with the template's default params.
params?: Record<string, unknown>;
// Path where the project is created
path?: string;
// The host name the application runs on. Defaults to 0.0.0.0
hostname?: string;
// The port the application runs on. Defaults to 3000
port?: number;
// Move the tokens and database parameters from this JSON to the project's .env (without the flag they are removed from the configuration)
isEnv?: boolean;
}
{
"name": "my-quiz-bot",
"type": "quiz",
"mode": "dev",
"path": "./bots/quiz",
"config": {
"json": "./data",
"error_log": "./logs",
"isLocalStorage": true,
"db": {
"host": "",
"user": "",
"pass": "",
"database": ""
},
"tokens": {
"alisa": {
"token": "token"
}
}
},
"isEnv": true
}
⚠️ In the example above, tokens and database parameters are shown as placeholder strings. In a real project it is recommended to leave them empty in the config and fill them in
.env, which the CLI creates in every project (it is already in.gitignore). With{ "isEnv": true }the values from the JSON are moved to.envautomatically.
| Type | Description | Features |
|---|---|---|
default |
Basic template | A minimal project structure |
quiz |
Quiz template | A ready-made structure for building quizzes |
| Mode | What is generated in src/index.ts |
|---|---|
prod |
Bot in the strict_prod mode and bot.start() — a webhook server (the default if there is no mode) |
dev |
BotTest and bot.test() — a dialog in the console, without a server |
dev-online |
Bot in the dev mode and bot.start() — a server with detailed logs |
build |
Runs through run(config, mode) from umbot/build; the mode is switched with one line in the file |
The create from-flow command creates an umbot project from a JSON file exported from Umbot Flow — the visual editor for the umbot framework.
The pipeline: visual editor → JSON configuration → npx umbot create from-flow → TypeScript project
A detailed description of the JSON format: src/docs/json-format.md
npx umbot create from-flow flow.json
npx umbot create from-flow flow.json --output ./my-bot
| Parameter | Description |
|---|---|
flow.json |
Path to the JSON file exported from the editor |
--output ./path |
Path for the output project (by default: the flow.json file name without extension) |
my-bot/
├── src/
│ ├── index.ts # Entry point with command registration
│ └── utils.ts # setText/setTTS helper functions
├── package.json
├── tsconfig.json
├── README.md # How to install, fill in tokens, run and connect platforms
├── .env # Token variables for the chosen platforms (not committed)
└── .gitignore
The .env file is always created: the token variables for the chosen platforms are empty if flow.json has no tokens.
On regeneration (--force), filled-in values are kept, missing variables are appended,
and empty ones are filled with tokens from flow.json. The generated bot reads .env from the folder it is started in.
String slots are generated in lower case: the user's utterance reaches the bot already lowercased, and a "Weather" slot
from the editor would otherwise never match. Regex slots (isPattern) stay as they are — write them for lowercase
text. More in the JSON format description.
The greeting (the welcome node, or the welcome text and buttons from the settings if there is no node) fires:
/start (Telegram, including with a deep-link parameter) and on the built-in Russian greeting slots ("hi"/"hello") or the node's own slots;messageId === 0):
in this case the fallback command calls the greeting.A step that was waiting for an answer in the previous session skips the dialog start (return false). Without a greeting the start goes to the fallback.
The bot mode (mode in flow.json) is generated as a bot.setAppMode(...) call right after Bot is created — before commands
are registered. Without the mode field (or with an unknown value) strict_prod is generated.
index.tsindex.ts;
no separate controller file is created in either modeflow.jsonnpx umbot create from-flow flow.json --output ./my-bot.env and start it (details are in the generated README.md):cd my-bot
npm install
npm run build
npm start
Project naming:
_
(npx umbot create my-bot creates the my_bot directory and the same name in package.json),
so use snake_case or a single-word nameConfiguration:
Project structure:
Full reference — API v-3.1 · all versions.