WebDocs · NodeSMS Live
Source
Back to WebDocs

NodeSMS Live Documentation

NodeSMS Live is an Express-based SMS webservice gateway that bridges GSM modems, SQL Server databases, and external messaging providers. It receives, processes, and routes SMS messages using configurable keyword triggers, while exposing monitoring endpoints and smart-messaging integrations.

SMS Gateway
Receive, parse, and dispatch SMS via GSM modems.
SQL-Backed
Persists messages and uses stored procedures on MSSQL.
Live Monitoring
Real-time streams for signal strength, pending, and outgoing SMS.

Architecture

The app initializes two GSM modem listeners and mounts route modules onto a shared Express router. Each module handles a responsibility:

ModuleResponsibility
service.jsApp bootstrap, modem setup, route mounting.
config.jsPorts, paths, DB config, SMS config.
sms-processing.jsModem receive, PDU mode, serial events.
sms-processing2.jsSecond modem variant.
sms-keywords-processing.jsKeyword parser → validation/procedure/result SQL.
send-smart-messaging-suite.jsOutbound SMS proxy endpoint.
monitoring.jsLive monitoring streams via SSE.

Tech Stack

Node.js Express MSSQL / mssql serialport serialport-gsm Socket.IO Axios Joi dotenv

Configuration — components/config.js

Central config exposes factories for ports, paths, secrets, and DB connections.

FunctionReturnsDescription
WebServiceKey()stringShared API key protecting endpoints.
WebServicePath()stringParent route path. Default: /api.
WebServicePort()numberListening port. Default: 3002.
ENV()objectParsed .env via dotenv.
SMSConfig()objectSerial port baud rate, data bits, parity, etc.
SQLConfig()objectMSSQL connection options.
sqlERPDb(env)stringERP DB name by environment.
sqlDashboardDB(env)stringDashboard DB name by environment.
sqlSMSACCDB(env)stringSMSACC DB name by environment.
ReturnResult(code, desc)arrayStandard response envelope.

SMS Processing — components/modules/sms-processing.js

Opens a serial GSM modem, initializes it into PDU mode, and listens for incoming SMS events.

Exports

SMSReceiving(comport, Gnumber, flag, description)
Opens modem on given COM port, sets PDU mode, and attaches event handlers. Gnumber is the source number label. Optional smart messaging suite enabled via flag.
SMSSignalStrength()
Returns a Promise that fetches current signal strength from the modem.

Smart Messaging Suite — send-smart-messaging-suite.js

Outbound SMS endpoints. Current implementation queues messages into the SMSACC inbox table; direct Smart HTTP integration is commented out.

GET /api/smart-messaging-suite/get

Query: key, source, destination, message

Requires matching webservice key. Inserts an ECHO message into SMSACC.dbo.inbox.

{
  "ResultCode": "Success!",
  "ResultDescription": "Message Successfully sent to Queue!"
}
POST /api/smart-messaging-suite/post

Body: key, source, destination, message

Same behavior as GET; accepts JSON body instead of query params.

Keyword Processing — sms-keywords-processing.js

Parses incoming SMS into uppercase keyword + parameters, then dynamically runs SQL validation/procedure/result queries based on the keyword table.

Export

SMSKeyWordsProcessing(SmsMessage, SmsSender, SMSName)

Returns a Promise. Loads keywords from SMSACC.dbo.keywords and executes the matched keyword workflow.

Supported Keywords
CONFIRM XZOUT TR SALES PING SQUERY HELP ECHO

Monitoring — components/modules/monitoring.js

Real-time Server-Sent Events (SSE) streams for operational visibility. Mounted at /api/monitoring.

SSE /api/monitoring/stream
Generates synthetic numeric telemetry every ~10s for dashboards.
SSE /api/monitoring/pending-sms
Streams pending inbound SMS records.
SSE /api/monitoring/sent-sms
Streams sent outbound SMS records.
SSE /api/monitoring/dashboard-pings
Emits modem signal-quality pings.
SSE /api/monitoring/top-keyword-used
Live ranking of most-used keywords from outbox.
SSE /api/monitoring/top-keyword-error
Top 5 keywords producing “Keyword Does not exist!” errors.

Databases

Environment-aware MSSQL database selection. Configured via components/config.js.

HelperDevelopment / StagingProduction
sqlERPDbtemporary_erperpdata_new
sqlDashboardDBmcjim_all_prog_testmcjim_all_prog
sqlSMSACCDBSMSACC_TESTSMSACC
sqlTAMSDB[192.168.42.25\\SQLEXPRESS2017].TAMSprod

Connection Details

Obtained from SQLConfig() in config.js. Contains server, credentials, timeout, and TLS options.

API Reference

Routes are mounted under /api unless otherwise noted. All protected routes require query/Body param key=MCJIM_Node_JS_SMS_Web_Service_Key_2022.

GET /api/monitoring
Monitoring dashboard root. Returns polling HTML/ECharts boilerplate inside monitoring.js.
SSE /api/monitoring/stream
Text/event-stream live telemetry for dashboard.
GET /api/smart-messaging-suite/get

Send outbound SMS via GET proxy.

Params: key, source, destination, message

POST /api/smart-messaging-suite/post

Send outbound SMS via JSON body.

Body: key, source, destination, message

Deployment

Server entrypoint: service.js

Default port: process.env.PORT || 3002

Environment: loads from .env via dotenv; used for ENVIRONMENT_VALUE to select databases.

Runtime: requires attached GSM modem(s) on configured COM ports.

Static middleware serves vendors/, images/, js/, css/.