In this challenge, we're going to explore Amazon Pinpoint to send SMS messages.
Make sure the following tools are installed.
The challenge requires an AWS account. AWS provides a Free Tier, which is sufficient for most challenges.
Next, you will need to clone this repo into your working directory:
git clone https://github.com/LambdaSharp/Pinpoint.git
The following command uses the dotnet
CLI to install the LambdaSharp CLI.
dotnet tool install --global LambdaSharp.Tool
NOTE: if you have installed LambdaSharp.Tool in the past, you will need to run dotnet tool update -g LambdaSharp.Tool
instead.
The following command uses the LambdaSharp CLI to create a new deployment tier on the default AWS account. Specify another account using --aws-profile ACCOUNT_NAME
.
lash init --quick-start
- Create a new project with AWS Pinpoint found in the AWS console
- Configure SMS & Voice
- Request a long code.
- Send a simple test message to your mobile phone
- Create a segment a. Use Import CSV file b. Download the example CSV for formatting c. Update the CSV file with mobile numbers & names for all group members - Use International phone numbers notation (e.g. 16195551234)
- Create a template that dynamically uses an attribute from your segment
- Create a campaign using the segment and template you created
- Choose to launch campaign immediately to get your personalized text message!
- Go to the
SurveySms/function.cs
file and update APP_ID with the Project ID from the web console - Deploy the LambdaSharp project
lash deploy
NOTE: Please wait for deploy to finish before moving to the next step
- Enable two-way SMS by going to Settings > SMS and voice > click on your long code number then enable two-way SMS
- Select the SNS topic with
My.Pinpoint
in the title - Reply to the text from your long code number and see the message appear in your CloudWatch logs. (Go to CloudFormation > My-Pinpoint > Resources then click on the
SurveySmsLogGroups
) link
Here is an example of what a message looks like:
{
"originationNumber": "+XXXXXXXXXX",
"destinationNumber": "+XXXXXXXXXX",
"messageKeyword": "keyword_045616484003",
"messageBody": "This is my response ",
"inboundMessageId": "8dc9d631-9133-5232-82a8-808675b4c07b",
"previousPublishedMessageId": "k7hd8hsna3vr9oqf49seqd5opnq302n64divurg0"
}
- Respond to the long code phone number with a question to the customer (via SMS in lambda function).
- Checkout the SDK information: https://docs.aws.amazon.com/pinpoint/latest/developerguide/send-messages-sms.html
- Ask 5 questions to a customer via 5 separate SMS messages. They must respond to each question before moving to the next.
- Provide a summary to the customer at the end of the 5th question.
https://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpNET.html https://docs.aws.amazon.com/AmazonS3/latest/dev/RetrievingObjectUsingNetSDK.html
Based on level 4, send an event to AWS Pinpoint notifying that the customer completed the survey. Show this to us at the end of the night!
https://docs.aws.amazon.com/cli/latest/reference/pinpoint/put-events.html https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Pinpoint/TPinpointClient.html https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Pinpoint/MPinpointPutEventsPutEventsRequest.html
- Go to Pinpoint > All projects > LambdaSharp > Settings > SMS and voice
- Select the phone number and click Remove long code