Somleng SMS Gateway is composed of three main parts: Client Application, Somleng, and the SMS Gateway App on Android. The SMS Gateway App maintains a persistent WebSocket connection to Somleng and uses the device’s SIM card to send and receive SMS, acting as a bridge between Somleng and the mobile network.
The outbound flow sends an SMS from your application to a recipient via Somleng and the SMS Gateway App:
- Client Application → Somleng: The client application sends a new outbound message request to Somleng's API.
- Somleng → SMS Gateway App (WebSocket): Somleng pushes a
message_send_requestWebSocket message to the SMS Gateway App associated with the target device. - App → Somleng: To ensure no other devices pick up the same message, the app sends a
message_send_requestedWebSocket message to Somleng. - Somleng → App: Somleng sends a reply
message_send_confirmedWebSocket message to the app, confirming that this device will handle sending the message. - App → Recipient (SMS): After receiving
message_send_confirmed, the app sends the SMS via the device’s SIM card to the recipient over the mobile network. - App → Somleng (status update): After the SMS is sent, the app sends a
sentWebSocket message so Somleng can update the delivery status for the client application.
The inbound flow delivers SMS messages received on the device to your application via Somleng:
- Sender → Device (SMS): An external sender sends an SMS message to the phone number of the device running the SMS Gateway App.
- Device → SMS Gateway App: The Android device receives the SMS message, and the SMS Gateway App detects the new inbound message.
- SMS Gateway App → Somleng (WebSocket): The app sends a
receivedWebSocket message to Somleng, including the message details. - Somleng → Client Application (HTTP webhook): Somleng creates an inbound message and invokes the configured HTTP webhook on the registered phone number on Somleng.
- Client Application: The client responds to Somleng with TwiML, which contains the instructions for handling the incoming message.

