I have been exploring Amazon Pinpoint for a while and came across two-way SMS support where a user can send an SMS to communicate with the AWS service. For example in the banking sector, the two-way SMS feature is leveraged for mobile number verification during app download. With this feature, one can automate a number of tasks. Here, is the flow that we are looking at.
Now, let’s see how we can set it up.
Request Long codes
Note: If you do not request long codes then your AWS Pinpoint account will be in a sandbox mode and cannot send SMS to users unless verified
To set up Amazon Pinpoint, dedicated long codes are required which is something you have to request via the AWS Service Limit Increase support case.
Long codes are phone numbers or virtual numbers which are different for different countries.
Open a Service Limit Increase support case with the required details as shown below.
After filling above details, next you have to add request in terms of Region, Resource Type, Limit and New Limit value. And multiple request can be added.
Task automation
We will use the AWS Lambda function to perform task automation which is further subscribed to the SNS topic (which we will create in the upcoming section). However, it could be anything else other than lambda function depending on the use-case
As a next step a create lambda function. Your automation/business logic will go into the lambda function like for example you want to start the demo instance when you are unable to reach your system or it could be an important communication or watering your plants via IoT while you are on vacation and many more.
Create SNS topic
The SNS topic will work as a bridge between Amazon Pinpoint and the Lambda function or other service (that you want to integrate for automation)
After creating the SNS topic, create lambda subscription.
Amazon Pinpoint Setup
Once the support request is processed, setup Amazon Pinpoint.
Create a project
Configure SMS and voice
Enable the SMS channel for this project and select Transactional as default message type with Account spending limit.
Navigate to SMS and voice under project settings to request phone number. Select the country and make sure that SMS channel is enabled.
Once you receive the phone number, open that.
Scroll down to Two-way SMS and enable it. For incoming messages destination select the SNS topic that we have created in the previous steps. Additionally, you can configure Keyword for an automated response.
Once, the above configuration is done you can send an SMS from your mobile phone and relax. This is how the response looks like.
Once, you send the message it will pass the payload to the SNS topic which will trigger a lambda function to perform automation.
You can also refer to a mentioned hands-on video where I have demonstrated the automation of the start & stop of an EC2 instance along with the email notification.
Happy automation!