/telegram-support-bot

Telegram support bot using the Telegraf framework.

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

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

Bot API Version NPM Version node js-standard-style

Documentation

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

Telegraf documentation.

Installation

Install Node ( > 6.2 ) and npm ( > 5 ).

Run it

git clone https://github.com/bostrot/telegram-support-bot.git
cd telegram-support-bot
npm i
node bin/support.js

Or: via install script (this will create two autostart files for systemctl and enable both):

git clone https://github.com/bostrot/telegram-support-bot.git
cd telegram-support-bot
sudo bash setup
sudo systemctl start YOUR_SUPPORT_BOT_SERVICE_NAME

Enter the bot location (ex. /home/bots/mybot.js) when asked and then your bot name (ex. mybot) setup will create two systemctl links in order that your bot will be automatically restarted when it crashes and runs in the background.

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.js:

module.exports = {
    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",
    supported_bot: "service_name", // service name of the supported bot leave empty if you don't have one
    startCommandText: "Welcome in our support chat! Ask your question here.",
    faqCommandText: "Check out our FAQ here: Address to your FAQ",
};

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 (userid) - lists some stuff from the database about the user

User commands:

  • /start - tells the user how to use this bot
  • /faq - shows the FAQ

This you should only care about when you intend to "support" another bot e.g. salesbot with this. This would enable "ANTI-CRASH" and commands like start and stop. Remember to use this only when you have two bots.

Admin/Owner commands:

  • /root - Starts the listener and prevents the bot from crashing (restarts it and sends the log into the staff chat); Also this will open up a dashboard where the admin/owner can control the bot with following Update, Restart, Log, Stop.

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

Bitcoin: 1ECPWeTCq93F68BmgYjUgGSV11XuzSPSeM

PayPal: paypal.me/bostrot

Hosting: Get $50 free VPS credit on Vultr