Recently I worked on an automation project where we needed to receive SMS messages. This was not my first time to deal with messages. In one of the older projects we needed a functionality to send out messages ourself.
In both of these cases we used an Android app named very appropriately: SMS Gateway. It is more developer-friendly than many other similar applications as it allows to use HTTP requests directly instead of more consumer-oriented methods.
In the case of receiving messages, the app will make an HTTP request to the configured URL with the sender number and message as the URL query parameters. When configured to send out messages, it acts as a web server that you can query from the backend of your system.
The gateway also needs a phone to run on. In the last project we used an Alcatel Pixi 3. It is a cheap Android phone, costing near 50-60 EUR, but runs a relatively recent Android 4.x version. It is currently running 24/7 on the charger. It's also power effient as the charger does not heat up. The latter might be a problem with some other phones. The network connection is done over WiFi. So far the setup has ran for two weeks and has been rock stable.