nestjs-telegram-helpdesk
v1.4.12
Published
Telegram Helpdesk Bot
Downloads
6
Readme
Description
It is an application designed to make a helpdesk via telegram. When a user writes to the support bot, it forwards the message to the support group, then one member of the support team replies the message, and it is being forwarded to the user.
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 or stickers will be forwarded too.
Currently, the support chat offers these commands (staff commands):
/id
- returns your telegram id and the group chat id (1234567 -1234567890)/close
- close a ticket manually (in case someone writes 'thank you')/reopen
- reopen a ticket manually/clear
- close all tickets in category or close all tickets in all categories when typed in staff chat
User commands:
/start
- prints all public support categories/cat
- print current support categories
Features:
- File forwarding from and to user
- Database for handling open and closed tickets
- Simple anti spam system
- Send tickets to different staff groups
- Anonymize users
Installation
Create a folder for the application, cd
into it. Then download and unpack the package here:
$ npm v nestjs-telegram-helpdesk dist.tarball | xargs curl | tar -xz --strip-components=1
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
.
Configuration
Rename example settings file:
$ mv settings.example.yml settings.yml
Settings
db
Database settings
host
port
username
password
redis
Redis for exchange with external process via Bull
optional. Used for support categories update in runtime required if tickets is defined
host
port
tickets
optional. Used for deletion of closed tickets
daysToKeepTickets
# How many days to keep closed tickets. 0 for infiniteremoveTicketsCron
# When to launch clean up
bull
Bull queues for external process exchange;
optional, required if "redis" is defined
appQueue: "app-queue-name"
# sends a message when application startscategoriesQueue: "cat-queue-name"
# listens to messages with support categories from external process
botToken
Support bot token
staffChatId
Admin's group. Accumulate messages from all categories
ownerId
Admin's telegram id
spamTime
time (in MS) in which user may send {spamCantMsg} messages
spamCantMsg
Maximum messages in {spamTime} MS
autoCloseTickets
Close tickets after answering
anonymousTickets
Include userid in tickets or not
categories
optional
Array of built-in support categories
- id: '100500' # category id
- name: 'Superchat' # category name
- groupId: '-100500' # telegram group id
- isPublic: true # public flag
Support categories
Adding support categories allows you to have invitation links:
https://t.me/{helpdesk_bot_name}?start={id}
helpdesk_bot_name
is your bot's usernameid
is category id from config. Unique string, e.g. UUID
Running the app
Docker
$ docker-compose up -d
PM2
Once
$ npm i -g pm2
$ mv ecosystem.config.example.js ecosystem.config.js
Every time you update the app
$ npm i --only=prod
$ npm run migration:prod
$ pm2 start ecosystem.config.js