Skip to content

Simple chat by using Node.js, Socket.IO and node-telegram-bot-api

License

Notifications You must be signed in to change notification settings

VDS13/Socketgram-Support-Chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

Socketgram - Support Chat

Simple project that combines database, Express, Socket.io and Telegram Bot API written in Node.js

Bot API Version Project Version

Introduction

The project is a technical support chat, with the ability to send messages both from the site page and from Telegram through a chat bot.

Libraries used

Node.js

PHP

  • LDAP
  • MySQL

Project composition

  1. Principle of operation
  2. Chat server
  3. Admin panel in PHP
  4. Client block

Principle of operation

There are two roles: admin and user. The admin has access to all rooms, the user - only to the one in which he is. Rooms are formed by hashing a string like: id + <ClientID> + Secret key. For example: md5("id123qwerty"). The connection of the admin to the server is determined by sending a request (query) when connecting (an example of the parameters is below in the configuration file):

io(DOMEN_SERVER, { transports : ['websocket', 'polling', 'flashsocket'], query : {[SERVER_KEY]: SERVER_PSWD} })

Let's consider two examples: when the user is authorized in the telegram bot and when the user is not authorized.

User 1: not logged in

The user sends a message from the site, the message arrives at the server via WebSockets, is written to the database and sent to the admin:

The response from the admin to the user follows the same principle:

User 2: logged in

The user sends a message from the site or Telegram, the message arrives at the server via WebSockets, is written to the database and sent to the admin:

The response from the admin to the user is sent through the admini panel via WebSockets, comes to the server, is recorded in the database and sent to the user's personal account and to Telegram via the Telegram bot:

License

The MIT License (MIT)

Copyright © 2022-2024 Dmitry Vyazin