
Data and dialogs
Your result: a bot that remembers a name, accepts only a valid quantity, and keeps a self-reported learning checklist between commands.
Before you start: use a working test bot with a private Telegram chat. You will create and edit BJS commands. The dialog and checklist helpers used here are included in the runtime. Complete First bot and menu if the bot does not reply yet.
Learn the JavaScript you will use
Prepare: choose a practice command that does not perform real payments or change another user's data.
Do: work through JavaScript basics for BJS beginners, including variables, conditions, loops, functions, and the /quote example.
Check: send the practice command and compare its reply with the example. Change an input value and explain why the result changes. Read What survives the next message? before continuing.
Next: store a value supplied by the person chatting with the bot.
Ask for a name
Prepare: create /name and configure its Answer and Wait for answer exactly as the guide describes. Add the shared /cancel command described above.
Do: follow Ask a question and collect the reply. Keep the full code in that guide as your source.
Check: /name asks a question first; replying with a name runs the BJS and stores display_name. Inspect it in User properties, then start another question and send /cancel to check that cancellation does not save it as a name.
Next: add validation instead of accepting any text.
Accept a valid quantity
Prepare: SmartAmountDialog is included in the runtime; no Store installation is needed. Keep the shared cancellation command. Do not add another /cancel with the same name.
Do: follow Ask for a quantity and validate the reply, using its /quantity command and its stated minimum and maximum.
Check: run the guide's whole test conversation: valid number, invalid text, out-of-range input, and cancellation. Confirm that demo_quantity changes only after a valid answer and that an invalid answer lets you try again.
Next: save progress across return visits.
Keep a learning checklist
Prepare: SmartTasker and SmartBot are included in the runtime. Use the private-chat setup from the checklist recipe. Check that /learn and /learn-done are available names in the test bot.
Do: follow Save progress in a learning checklist, keeping its task names and the two command examples together.
Check: open /learn, mark a task, then open /learn again. Follow the recipe's repeated-completion and unknown-task tests too. The checklist records the user's claim; it does not automatically verify that a lesson was completed.
Next: connect external services, or choose a data recipe.
Finish the route
Check all three flows again in the same bot. /cancel must work for either question; the stored name, quantity, and checklist must remain separate. If a known command unexpectedly answers a question, review waiting for a reply.
Last updated
Was this helpful?
