A minimal TypeScript CLI chatbot built using the diaflow-gemini SDK.
This example demonstrates how to connect to Google Gemini 2.0 Flash via DiaFlow and interact through your terminal.
- ⚡ Minimal setup — less than 50 lines of code
- 💬 Interactive terminal chat (type & get instant responses)
- 🔐 Secure API key loading via
.env - 🧩 Built with modern TypeScript and Node 22+
git clone https://github.com/tanmayvaij/diagem-cli-bot.git
cd diagem-cli-botnpm installCopy the example file and edit it:
cp .env.example .envThen open .env and paste your Gemini API key:
GEMINI_API_KEY=your_api_key_here
You can get a key from the Google AI Studio Console.
Run with tsx:
npx tsx main.tsExample session:
USER : hi
AI : Hello! How can I help you today?
USER : write a haiku about TypeScript
AI : Static types sing loud,
JavaScript’s calm evolution,
Errors fade away.
Type exit to quit the session.
diagem-cli-bot/
├── .env.example # Template for API key
├── main.ts # Core CLI logic
├── package.json # Dependencies & metadata
└── README.md # You're reading it!
- Loads your API key from
.env - Initializes a
diaflow-geminiAgent with Gemini 2.0 Flash - Opens a readline interface to accept user prompts
- Sends each prompt to the LLM and prints the response
- Node.js (v22+)
- TypeScript
- diaflow-gemini
- dotenv
- readline/promises
- Quick LLM experimentation
- Local chatbot or CLI assistant
- Base for plugin-style terminal tools
- Teaching resource for
diaflow-geminiSDK
MIT © Tanmay Vaij