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.
Architecture
The app initializes two GSM modem listeners and mounts route modules onto a shared Express router. Each module handles a responsibility:
| Module | Responsibility |
|---|---|
service.js | App bootstrap, modem setup, route mounting. |
config.js | Ports, paths, DB config, SMS config. |
sms-processing.js | Modem receive, PDU mode, serial events. |
sms-processing2.js | Second modem variant. |
sms-keywords-processing.js | Keyword parser → validation/procedure/result SQL. |
send-smart-messaging-suite.js | Outbound SMS proxy endpoint. |
monitoring.js | Live monitoring streams via SSE. |
Tech Stack
Configuration — components/config.js
Central config exposes factories for ports, paths, secrets, and DB connections.
| Function | Returns | Description |
|---|---|---|
WebServiceKey() | string | Shared API key protecting endpoints. |
WebServicePath() | string | Parent route path. Default: /api. |
WebServicePort() | number | Listening port. Default: 3002. |
ENV() | object | Parsed .env via dotenv. |
SMSConfig() | object | Serial port baud rate, data bits, parity, etc. |
SQLConfig() | object | MSSQL connection options. |
sqlERPDb(env) | string | ERP DB name by environment. |
sqlDashboardDB(env) | string | Dashboard DB name by environment. |
sqlSMSACCDB(env) | string | SMSACC DB name by environment. |
ReturnResult(code, desc) | array | Standard 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)
Gnumber is the source number label. Optional smart messaging suite enabled via flag.SMSSignalStrength()
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.
/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!"
}
/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.
Monitoring — components/modules/monitoring.js
Real-time Server-Sent Events (SSE) streams for operational visibility. Mounted at /api/monitoring.
/api/monitoring/stream
/api/monitoring/pending-sms
/api/monitoring/sent-sms
/api/monitoring/dashboard-pings
/api/monitoring/top-keyword-used
/api/monitoring/top-keyword-error
Databases
Environment-aware MSSQL database selection. Configured via components/config.js.
| Helper | Development / Staging | Production |
|---|---|---|
sqlERPDb | temporary_erp | erpdata_new |
sqlDashboardDB | mcjim_all_prog_test | mcjim_all_prog |
sqlSMSACCDB | SMSACC_TEST | SMSACC |
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.
/api/monitoring
monitoring.js./api/monitoring/stream
/api/smart-messaging-suite/get
Send outbound SMS via GET proxy.
Params: key, source, destination, message
/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/.