Flow bot
Is a simple framework for creating Telegram bots based on intuitive json flows
- Add bot to your project using
npm install --save-dev jdi-flow-bot
- Create json flow for your bot:
flow = { screens: BotScreen[], events: BotEvent[] }
- Run flow bot using your json screen flow
import flow from './flow-bot/screens/flow.json';
import {FlowBot} from 'jdi-flow-bot/flow-bot';
import 'dotenv/config';
new FlowBot(process.env.BOT_TOKEN, flow).start();
Screen file example:
{
"screens": [
{
"command": "/start",
"description": "Start screen",
"image": "start1.jpg",
"text": "Hello world",
"buttons": [
[
{ "text": "Sun", "callback_data": "sun" }
],
[
{ "text": "Sky", "callback_data": "sky" },
{ "text": "Water", "callback_data": "water" }
]
]
},
{
"command": "/sun",
"image": "sun.jpg",
"text": "Some info about sun",
"buttons": [ [ { "text": "Back", "callback_data": "start"} ] ]
},
{
"command": "/sky",
"image": "sky.jpg",
"text": "Some info about sky",
"buttons": [ [
{ "text": "Sun", "callback_data": "sun"},
{ "text": "Back", "callback_data": "start"}
] ]
},
{
"command": "/water",
"image": "water.jpg",
"text": "Some info about water",
"buttons": [
[ { "text": "Sky", "callback_data": "sky"} ],
[ { "text": "Back", "callback_data": "start"} ],
]
}
],
"events": [ ]
}