Building A Telegram Bot With Node.js And Telegraf
Build a Telegram bot with Node.js & Telegraf! This comprehensive guide covers project structure, commands (hi, preview, publish), user input handling, session data management & draft system implementation
In my previous article, we configured the project and wrote a simple, workable bot. We want to teach it to react to users' messages and have a memory to interact with the drafts. Types It is time to define some entities representing our bot application. Put it under the source directory and put it into the types.ts file. // src/types.ts import { Context as TelegrafContext } from 'telegraf'; import type { Message as TGMessage } from 'telegraf/types'; export type Message = { text?: TGMessage.TextMessage; photo?: TGMessage.PhotoMessage; video?: TGMessage.VideoMessage; }; ex...