Create New GramIO Bot
You are scaffolding a new GramIO Telegram bot project.
Arguments
The user may provide:
- •
[project-name]— directory name for the project (default: current directory) - •Optional flags or preferences (e.g., runtime, plugins to include)
Steps
- •
Check if
create-gramiois available:- •The recommended way is
npm create gramio [project-name](or bun/pnpm/yarn equivalent). - •If the user wants a custom setup instead, proceed with manual scaffolding below.
- •The recommended way is
- •
If using
create-gramio(recommended):bashnpm create gramio [project-name]
Then help the user configure the generated project.
- •
If manual scaffolding, create the project structure:
code[project-name]/ src/ index.ts # Main bot entry point .env # BOT_TOKEN=your_token_here .env.example # BOT_TOKEN= (template) .gitignore # node_modules, .env, dist package.json tsconfig.json - •
src/index.ts— basic bot setup:typescriptimport { Bot } from "gramio"; const bot = new Bot(process.env.BOT_TOKEN as string) .command("start", (context) => context.send("Hello! I'm powered by GramIO.") ) .onStart(({ info }) => { console.log(`Bot @${info.username} started!`); }) .onError(({ context, kind, error }) => { console.error(`[${kind}]`, error); }); bot.start(); - •
package.json— include gramio and dev scripts:json{ "name": "[project-name]", "type": "module", "scripts": { "dev": "bun --watch src/index.ts", "start": "bun src/index.ts" }, "dependencies": { "gramio": "latest" } } - •
Install dependencies:
bashcd [project-name] && bun install
- •
Add recommended plugins if the user wants them:
- •
@gramio/sessionfor user data - •
@gramio/autoloadfor file-based handler loading - •
@gramio/auto-retryfor resilient API calls
- •
- •
Remind the user to:
- •Set
BOT_TOKENin.env - •Run
bun run devto start developing
- •Set