Services like Twilio and MailSlurp offer phone number and SMS APIs that can be used to build SMS routing functionality for automation and testing.

Create phone numbers

Create a phone number for a given region in the MailSlurp dashboard.

You can then access and control the phone number using the MailSlurp API client.

Redirect SMS with webhooks

Create a webhook for your phone number to route incoming SMS messages to your endpoint of choice, be that a server, slack, or lambda function.

Wait for arrival of SMS

In tests or automation logic you can hold a connection open until an expected SMS txt message is received:

Reading text messages in code

Extract SMS message content like so: