Coder Social home page Coder Social logo

albysabu9 / telegram-support-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bostrot/telegram-support-bot

0.0 0.0 0.0 360 KB

Telegram support bot using the Telegraf framework.

License: GNU General Public License v3.0

JavaScript 8.19% Dockerfile 0.41% TypeScript 91.39%

telegram-support-bot's Introduction

Bot API Version NPM Version node js-standard-style

is a support bot for telegram bots, using the Telegraf framework (by @dotcypress). It lets users create tickets which will be send to a staff group and can be answered by a reply.

Documentation

telegram-support-bot was built on top of Telegraf libary.

Telegraf documentation.

Installation

Install Node ( > 8 ) and npm ( > 3.38.0 ).

Run it

git clone https://github.com/bostrot/telegram-support-bot.git
cd telegram-support-bot
npm i
cp config/config-sample.ts config/config.ts     # Adjust settings in config.ts
npm run prod                                    # For debugging: npm run dev

Configuration

You can get your ID with /id. The first number will be yours the second the one from the group you are in (if you are in one; including the minus).

You need to set your bot token and chat ids in config.ts:

    // bot settings
    bot_token: 'YOUR_BOT_TOKEN', // support bot token
    staffchat_id: 'SUPERGROUP_CHAT_ID', // telegram staff group chat id eg. -123456789
    owner_id: 'YOUR_TELEGRAM_ID',
    spam_time: 5 * 60 * 1000, // time (in MS) in which user may send 5 messages
    allow_private: false, // Allow / disallow option for staff to chat privately
    auto_close_tickets: true, // Closes messages after reply

If you replace categories: false with following snippet, you enable the subgroup system. This will allow the user to select a subcategory (e.g. for specified staff). If a chat has the same ID as the staffchat_id you can e.g. create a help chat for using the bot.

    // subgroups for different subcategories in JS Array -> Object format
    categories:
    [
      {
        name: 'Category1', subgroups: [
          {name: 'Sub1', group_id: '-12345678910'},
          {name: 'Sub2', group_id: '-12345678910'},
          {name: 'Sub3', group_id: '-12345678910'},
        ],
      },
      {
        name: 'Category2', subgroups: [
          {name: 'Sub4', group_id: '-12345678910'},
          {name: 'Sub5', group_id: '-12345678910'},
          {name: 'Sub6', group_id: '-12345678910'},
        ],
      },
      {
        name: 'Category3', group_id: '-12345678910'
      },
      {
        name: 'Admin Chat', group_id: '-12345678910' 
      },
    ],

Features

When a user sends a message to the support chat it will create a ticket which will be forwarded to the staff group. Any admin in the staff group may answer that ticket by just replying to it. Salutation is added automatically. Photos will be forwared too.

Currently the support chat offers these commands (staff commands):

  • /open - lists all open tickets (messages where noone has replied yet)
  • /close - close a ticket manually (in case someone writes 'thank you')
  • /id - returns your telegram id and the group chat id (1234567 -1234567890)
  • /ban - ban a person from writing to your chat

User commands:

  • /start - tells the user how to use this bot
  • /help - an overview over the commands or some explanation for the user
  • /faq - shows the FAQ

Features:

  • File forwarding from and to user
  • Database for handling open and closed tickets
  • Restrict users
  • Simple anti spam system
  • Send tickets to different staff groups
  • Private reply to user

Docker

via docker-compose:

docker-compose up -d

or build:

docker build -t bostrot/telegram-support-bot:latest .
docker run bostrot/telegram-support-bot -v /path/to/config_dir:/bot/config

Update to v1.0.1

Backup and delete the database file (src/support.db) and move config.js to folder config. Then just start it normally.

Telegram token

To use the Telegram Bot API, you first have to get a bot account by chatting with BotFather.

BotFather will give you a token, something like 123456789:AbCdfGhIJKlmNoQQRsTUVwxyZ.

Creating a bot

Telegraf bot framework for building a bot

Help

You are welcome to contribute with pull requests, bug reports, ideas and donations. Join the forum if you have any general purpose questions: bostrot.com

Hit me up for a custom hosting solution or other help on Telegram @bostrot_bot

telegram-support-bot's People

Contributors

bostrot avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.