This is a demonstration app that utilizes the SMS Gateway for Android™ to create an SMS management web interface. It leverages webhooks to display received SMS messages in real-time and provides the capability to send SMS messages.
- Connect to any account registered on the Cloud/Private server.
- Real-time receipt of SMS messages.
- Capability to send SMS messages.
The application does not store credentials anywhere, except in the session memory, which is cleared upon logout. Received and sent SMS messages are not stored at all for now.
- Node.js
- npm or yarn
- Clone the repository:
git clone <repository-url>
- Navigate into the project directory:
cd web-client-ts
- Install dependencies:
or if you use yarn:
npm install
yarn install
To configure the application, create a .env
file in the project root directory. This file should contain your environment variables, which include:
HTTP__PORT
orPORT
: Specifies the port on which the server listens.HTTP__SESSION_SECRET
: A secret key for session encryption.GATEWAY__URL
: The URL of the gateway API.GATEWAY__WEBHOOK_URL
: The external address of the server, appended with/api/webhooks
, to receive webhooks.NODE_ENV
: Set todevelopment
to enable development mode.
For more detailed information on the configuration options, please refer to src/config.ts
.
-
To run in development mode:
npm run dev
or
yarn dev
-
To build the project:
npm run build
or
yarn build
-
To start the server:
npm start
or
yarn start
After starting the server, navigate to http://localhost:<your-configured-port>
to view the application.
This app uses socket.io for real-time communication.
Client always listens to events login:success
and login:fail
. The first one indicates that client successfully logged in by previously sending login
event or saved in session credentials. The second one indicates that login attempt failed, current credentials can't be used anymore or session expired.
Typical sequences:
- Client sends
login
event with credentials to login. - Server responds with
login:success
orlogin:fail
event. - Client sends
sms:send
event with message to send new message. Server sends acknowledgement with success or failure. - Server sends
sms:received
event with newly received message. - Client sends
logout
event to destroy session.
login
with{login: string, password: string}
payload - login attempt. Server responds bylogin:success
orlogin:fail
event.sms:send
with{phoneNumber: string, message: string}
payload - send SMS message. Server uses acknowledgement to respond with payload{success: boolean, message?: string}
.logout
- destroy session, server responds bylogin:fail
event.
sms:received
with{phoneNumber: string, message: string, receivedAt: Date}
payload - received SMS message. The client should add received message to the list.login:success
- login successful. The client should move from login screen to messaging screen.login:fail
- login failed. The client should move to login screen if it is not already there.
Contributions are welcome! Please feel free to submit a pull request.
This project is licensed under the Apache-2.0 License - see the LICENSE
file for details.