jdi-flow-bot
TypeScript icon, indicating that this package has built-in type declarations

1.0.17 • Public • Published

Flow bot

Is a simple framework for creating Telegram bots based on intuitive json flows

  1. Add bot to your project using npm install --save-dev jdi-flow-bot
  2. Create json flow for your bot: flow = { screens: BotScreen[], events: BotEvent[] }
  3. 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": [ ]
}

Package Sidebar

Install

npm i jdi-flow-bot

Weekly Downloads

11

Version

1.0.17

License

Apache-2.0

Unpacked Size

41.7 kB

Total Files

34

Last publish

Collaborators

  • roman-iovlev